[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
Fri Apr 20 12:40:56 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: Open
Resolution: None
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
Assigned to: Nobody (None)
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


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

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