Class Spec::Mocks::OrderGroup

  1. lib/spec/mocks/order_group.rb
Parent: Object

Methods

public class

  1. new

public instance

  1. consume
  2. handle_order_constraint
  3. ready_for?
  4. register

Public class methods

new (error_generator)
[show source]
# File lib/spec/mocks/order_group.rb, line 4
      def initialize error_generator
        @error_generator = error_generator
        @ordering = Array.new
      end

Public instance methods

consume ()
[show source]
# File lib/spec/mocks/order_group.rb, line 17
      def consume
        @ordering.shift
      end
handle_order_constraint (expectation)
[show source]
# File lib/spec/mocks/order_group.rb, line 21
      def handle_order_constraint expectation
        return unless @ordering.include? expectation
        return consume if ready_for?(expectation)
        @error_generator.raise_out_of_order_error expectation.sym
      end
ready_for? (expectation)
[show source]
# File lib/spec/mocks/order_group.rb, line 13
      def ready_for?(expectation)
        return @ordering.first == expectation
      end
register (expectation)
[show source]
# File lib/spec/mocks/order_group.rb, line 9
      def register(expectation)
        @ordering << expectation
      end