[rspec-users] Expecting arbitrary method calls in a particular order
pergesu at gmail.com
Sun Jul 13 10:32:58 EDT 2008
On Sun, Jul 13, 2008 at 9:49 AM, Sven Fuchs <svenfuchs at artweb-design.de> wrote:
> I've been wondering how to expect arbitrary methods being called in a
> particular order. The RSpec documentation for expecting method calls on mock
> objects mentions that it is possible to pass a block to #should_receive, but
> does not mention that it can be used to track the method call order pretty
> Is there a better way of doing this?
> If not, do you think it would make sense to add this to the RSpec docs?
Mock objects have an optional notion of ordering. Check out the following spec:
describe "a mock object" do
it "should expect ordered messages" do
foo = mock("ordered mock")
Changing the order in which they're called will raise an ExpectationNotMetError.
More information about the rspec-users