1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
module RSpec
module Mocks
# @private
class OrderGroup
def initialize
@ordering = Array.new
end
# @private
def register(expectation)
@ordering << expectation
end
# @private
def ready_for?(expectation)
@ordering.first == expectation
end
# @private
def consume
@ordering.shift
end
# @private
def handle_order_constraint(expectation)
return unless @ordering.include?(expectation)
return consume if ready_for?(expectation)
expectation.raise_out_of_order_error
end
def clear
@ordering.clear
end
def empty?
@ordering.empty?
end
end
end
end
|