[rspec-devel] [ rspec-Bugs-10263 ] mock " leak" when setting an expectation in a block passed to mock#should_receive

noreply at rubyforge.org noreply at rubyforge.org
Thu Oct 18 20:42:46 EDT 2007


Bugs item #10263, was opened at 2007-04-20 16:40
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10263&group_id=797

Category: mock module
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
>Assigned to: David Chelimsky (dchelimsky)
>Summary: mock "leak" when setting an expectation in a block passed to mock#should_receive

Initial Comment:
The following failing examples should tell the story:

describe "Mock" do
  before do
    @mock = mock("test mock")
  end
  
  specify "when one example has an expectation (non-mock) inside the block passed to the mock" do
    @mock.should_receive(:msg) do |b|
      b.should be_true #this call exposes the problem
    end
    @mock.msg(false) rescue nil
  end
  
  specify "then the next example should behave as expected instead of saying" do
    @mock.should_receive(:foobar)
    @mock.foobar
    @mock.rspec_verify
    begin
      @mock.foobar
    rescue => e
      e.message.should == "Mock 'test mock' received unexpected message :foobar with (no args)"
    end
  end 
end


----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-10-19 00:42

Message:
Went to add this as pending and it turns out it got fixed. I have no idea when, but I suspect it was one of Antti Tarvainen's patches right after RailsConfEU.

Thanks AT!

Cheers,
David

ps - I did add the example above to the spec suite in r2738

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10263&group_id=797


More information about the rspec-devel mailing list