Topic: Odd test fails with $stdout

I'm trying to test some output that is placed in the console line for a script that I am writing.  In rspec I'm using this test: 

$stdout.should_receive(:puts).with('this transaction is not acceptable.')
    create_update(bad_courier_file)

and I get this:

Failure/Error: create_update(bad_courier_file)
     NoMethodError:
       undefined method `puts' for #<IO:<STDOUT>>

But when I put text that is incorrect, like:

$stdout.should_receive(:puts).with('this transaction is not acceptable.\n')
    create_update(bad_courier_file)

Then I get this:

Failure/Error: create_update(bad_courier_file)
       #<IO:0x0000010086fe10> received :puts with unexpected arguments
         expected: ('this transaction is not acceptable.\n')
              got: ('this transaction is not acceptable.')

What gives?  I've looked all over the place for an answer, so any help would be greatly appreciated.

Last edited by dsullivan (2012-01-20 15:10:59)