[rspec-users] Surprised by stub/mock interaction

Jeff Talbot jeff.a.talbot at gmail.com
Wed Feb 25 11:10:07 EST 2009


Something I do often is use stub methods in before blocks and mock
expectations in a specific examples (much like described here:

I was just surprised with an instance of doing this and I thought I'd check
with the group to see if I shouldn't have been.

What should be the expected output of the following -- assume it's the only
code in a spec file:

  class Foo; def bar; end; end

  it "should print something" do
    foo = Foo.new
    puts foo.bar
    puts foo.bar

I expected "false / false". The actual output is "false / true".

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090225/771953f7/attachment.html>

More information about the rspec-users mailing list