Hi,
I have a program that prompts the user on the command line to enter some
data. What are some ways to unit test the method that obtains the
input?
Hi,
I have a program that prompts the user on the command line to enter some
data. What are some ways to unit test the method that obtains the
input?
7stud – wrote:
Hi,
I have a program that prompts the user on the command line to enter some
data. What are some ways to unit test the method that obtains the
input?
I’m not sure if you found an answer to this. I came across your post
when I was looking for an answer to the same thing. The best way I
found is to use flexmock (or other mock tool).
flexmock($stdout){|mock| mock.should_receive(“puts”).with(“enter
something”)}
flexmock($stdin){|mock| mock.should_receive(“gets”).and_return(“junk”)}
Kurt Walker wrote:
7stud – wrote:
Hi,
I have a program that prompts the user on the command line to enter some
data. What are some ways to unit test the method that obtains the
input?I’m not sure if you found an answer to this. I came across your post
when I was looking for an answer to the same thing. The best way I
found is to use flexmock (or other mock tool).flexmock($stdout){|mock| mock.should_receive(“puts”).with(“enter
something”)}
flexmock($stdin){|mock| mock.should_receive(“gets”).and_return(“junk”)}
Thanks.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs