[rspec-devel] [ rspec-Bugs-4690 ] Ordering of mock calls doesn't work in block mode

noreply at rubyforge.org noreply at rubyforge.org
Fri Oct 27 04:01:08 EDT 2006


Bugs item #4690, was opened at 2006-06-06 16:31
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=4690&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Aslak Hellesoy (aslak_hellesoy)
Assigned to: Nobody (None)
Summary: Ordering of mock calls doesn't work in block mode

Initial Comment:
Two failing (and disabled) tests have been added to mock_ordering_test.rb to demonstrate this.

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

Comment By: Brian Takita (btakita)
Date: 2006-10-27 01:01

Message:
I'm getting an issue with the ordered should_receive(:doit) being called twice.

It seems the first expectation wins and the second expectation never gets considered.

It also seems that the block is a red herring.

try:

specify "should pass two calls in order to the same method" do
   @mock.should_receive(:doit).ordered.with("a1", "b1")
   @mock.should_receive(:doit).ordered.with("a1", "b2")
   @mock.doit "a1", "b1"
   @mock.doit "b1", "b2"
   @mock.__verify
end


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

Comment By: Aslak Hellesoy (aslak_hellesoy)
Date: 2006-10-14 06:19

Message:
Moving the tests here:

      def FIXME_test_two_in_order_calls_with_block
        @mock.should_receive(:doit).ordered do |a, b|
          a.should_equal "a1"
          a.should_equal "b1"
        end
        @mock.should_receive(:doit).ordered do |a, b|
          a.should_equal "a2"
          a.should_equal "b2"
        end
        @mock.doit "a1", "b1"
        @mock.doit "b1", "b2"
        @mock.__verify
      end

      def FIXME_test_two_out_of_order_calls_with_block
        @mock.should_receive(:doit).ordered do |a, b|
          a.should_equal "a1"
          a.should_equal "b1"
        end
        @mock.should_receive(:doit).ordered do |a, b|
          a.should_equal "a2"
          a.should_equal "b2"
        end
        @mock.doit "b1", "b2"
        @mock.doit "a1", "b1"
        @mock.__verify
      end


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

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


More information about the rspec-devel mailing list