[rspec-users] Expecting arbitrary method calls in a particular order

Ashley Moran ashley.moran at patchspace.co.uk
Sun Jul 13 11:44:42 EDT 2008


On Jul 13, 2008, at 4:35 pm, Sven Fuchs wrote:

> describe "Expecting the order of methods being called on arbitrary  
> objects" do
>  it "works" do
>    first = mock('first')
>    second = mock('second')
>
>    chain = Chain.new
>    chain << first
>    chain << second
>
>    second.should_receive(:run).ordered
>    first.should_receive(:run).ordered
>    chain.run
>  end
> end



Hi Sven

I think you want

   second.should_receive(:run) do
     first.should_receive(:run)
   end

which, if Mail.app is running my specs correctly, should only pass if  
second receives :run before first

Is that what you were after?

Ashley



-- 
http://www.patchspace.co.uk/
http://aviewfromafar.net/



More information about the rspec-users mailing list