[Rspec-users] overriding mock expectations

Micah Martin micah at 8thlight.com
Mon Oct 23 23:02:47 EDT 2006

Here's a quick fix....

in mock.rb in the add method ...
       def add(expectation_class, expected_from, sym, &block)
         expectation = expectation_class.send(:new, @name,  
@expectation_ordering, expected_from, sym, block_given? ? block : nil)
	@expectations << expectation

Line 47 could read:
	@expectations.insert(0, expectation)
instead of
	@expectation << expectation

As for a test...er spec....

specify "Mock expectations are overrideable" do
	m = mock("blah")

Micah Martin
8th Light, Inc.

On Oct 23, 2006, at 5:55 PM, Steven R. Baker wrote:

>> What I would like to do is define all the should_receives once in  
>> the setup using any_number_of_times.  This establishes a default  
>> context.  Then in each spec I'd like to override a specific  
>> should_receive relevant to the spec.
>> Without being able to override, I am force to define all the  
>> should_receives for each spec..... duplication.
>> Is there another solution I'm missing?
> We need you to write a patch for this.
> If you don't feel confident doing it, I'll take a crack at it when  
> I get home if you harass me on IM.
> srbaker0 yahoo
> stevenrbaker at mac.com .mac
> srbaker0 at hotmail.com msn
> -Steven

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061023/bd32afd3/attachment.html 

More information about the Rspec-users mailing list