[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: strategy for unit testing user input?

Kurt Walker

10/12/2007 11:06:00 PM

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")}
--
Posted via http://www.ruby-....

1 Answer

7stud --

10/13/2007 3:19:00 PM

0

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.
--
Posted via http://www.ruby-....