Hi,

I have, what seems to be, a strange problem. I have googled, but can't 
anything related to this, with any solutions.

I am putting together a command suite, and need to test the output to 
STDOUT. I have an output controller which other controllers utilize to 
output the results of their operations, the output controller simply prints 
the supplied message to STDOUT at the moment.

I test for the output with:

STDOUT.should_receive(:print).with(string_to_test_for)

All of the controller tests so far pass fine with all of the output being 
confirmed with the above matcher.

I have just added a new controller, and now get the following error when 
the *actual* output *matches* the *expected* output:

     Failure/Error: @controller.create(params)
     NoMethodError:
       undefined method `print' for #<IO:<STDOUT>>

The stack trace refers back to the line in my output controller which 
prints to STDOUT -> STDOUT.print msg

 However, when actual does not match expected I get the correct rspec 
exception confirming the output that was not received:

       #<IO:0x007fb4b20716b0> received :print with unexpected arguments
         expected: ("imported: ~/.application_data.po.con")
              got: ("imported: ~/.application_data.po.conf")

If I change the matcher to:

STDOUT.should_receive(:print).at_least(:once)

then the tests pass fine.

Obviously, the print method does exist on STDOUT, but for some reason when 
the matcher matches, it is resulting in this 'no print method error' for 
STDOUT.

Has anyone got any ideas why this is happening? 

(OSX, Ruby1.9.3p194, Rspec 2.10.0)

Any pointers would be greatly appreciated while I will continue to 
investigate myself. If I find the problem, I will post back here. If anyone 
needs any more info in order to help, let me know, and I'll post it ASAP.

Thanks

Paul



-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rspec/-/FiCttsJusscJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to