This used to work with blocks:
Though I haven't tried this since forever, so YMMV :)
@foca hey, that worked, thanks. It's not pretty, but it will do the trick.
@lukeredpath - check out http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/MessageExpectation:ordered
@dchelimsky does that work across different objects/mocks or only within the scope of a single receiver?
Recollection is it works across objects, but the docs and specs don't say or specify that. Give it a whirl and let me know and I'll update the docs to answer that question.
I assume you can still use Mocha with RSpec? Get your lovely sequences here ;-)
@floehopper - the docs only show a single receiver - do they work across objects?
Yes. I believe they do work across objects :-
class FooTest < Test::Unit::TestCase
sequence = sequence(:task_order)
task_one = mock("task_one")
task_two = mock("task_two")
I've added issue floehopper/mocha#59 to improve the examples in the docs. Thanks.
Just tried it with both rspec and mocha and both do a less than desirable job. rspec doesn't enforce order across objects (so only mocha satisfies @lukeredpath's issue right now), but it's messaging is clear when order is violated within one object:
1) something does something
Double received :bar out of order
# ./example_spec.rb:10:in `block (2 levels) in <top (required)>'
Mocha does enforce order across objects, but its messaging is unclear. Here's the result of the example with the last two lines reversed, e.g.
unexpected invocation: #<Mock:task_two>.execute()
- expected exactly once, not yet invoked: #<Mock:task_one>.execute(any_parameters); in sequence :task_order
- expected exactly once, not yet invoked: #<Mock:task_two>.execute(any_parameters); in sequence :task_order
Looks like we both have some work to do :)