[rspec-users] Stub that returns hash values

Carl Graff carl.graff at cox.net
Tue Oct 20 12:36:28 EDT 2009


Is it possible to create a stub that returns hash values.

For example I would like to convert this:
   @siteItem = stub('plmSiteItem', :one => "uno")

To something like this:
   @siteItem = stub('plmSiteItem', {'one' => 'uno', 'two' => 'dos'} )

So that I can do this:
    @siteItem['one'] should == 'uno'
    @siteItem['two'] should == 'dos'


Actually I first tried to use method double instead of stub - even 
though I still don't know when each is preferred - but double raised a 
missing method error for some reason.

 



More information about the rspec-users mailing list