Reputation: 142
I am new to ruby mocha and need to mock a method which is also a hash. Currently the method does two things:
Products.elements.oldest # returns the oldest element
Products.elements['second'] # returns the second element
and what i did was
Products.stubs(:elements).returns(mock, {'second' => mock})
Products.elements.stubs(:oldest).returns mock
I am not sure if this is the right way to do that, but it passes the compiler.
Upvotes: 1
Views: 199