On Apr 2, 2011, at 6:20 AM, Kai Schlamp wrote:

> I use RSpec mock and stub like this:
> 
> hit = mock("hit", :stored => 5)
> 
> This works fine, but when using this instead:
> 
> hit = mock("hit").stub(:stored) { 5 }

Not that it's really necessary, but to make this work you can do:

hit = mock('hit').tap {|h| h.stub(:stored) { 5 } }

although I prefer passing a hash into mock, much cleaner :)

Pat
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to