Method: RSpec::Mocks::MessageExpectation#ordered

Defined in:
lib/rspec/mocks/message_expectation.rb

#ordered(&block) ⇒ MessageExpectation

Expect messages to be received in a specific order.

Examples:

expect(api).to receive(:prepare).ordered
expect(api).to receive(:run).ordered
expect(api).to receive(:finish).ordered

Returns:



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/rspec/mocks/message_expectation.rb', line 379

def ordered(&block)
  if type == :stub
    RSpec.warning(
      "`allow(...).to receive(..).ordered` is not supported and will " \
      "have no effect, use `and_return(*ordered_values)` instead."
    )
  end

  self.inner_implementation_action = block
  additional_expected_calls.times do
    @order_group.register(self)
  end
  @ordered = true
  self
end