Class: Spec::Mocks::OrderGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/gems/rspec-1.1.12/lib/spec/mocks/order_group.rb

Instance Method Summary collapse

Constructor Details

#initialize(error_generator) ⇒ OrderGroup

Returns a new instance of OrderGroup.



4
5
6
7
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/order_group.rb', line 4

def initialize error_generator
  @error_generator = error_generator
  @ordering = Array.new
end

Instance Method Details

#consumeObject



17
18
19
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/order_group.rb', line 17

def consume
  @ordering.shift
end

#handle_order_constraint(expectation) ⇒ Object



21
22
23
24
25
# File 'lib/gems/rspec-1.1.12/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) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/order_group.rb', line 13

def ready_for?(expectation)
  return @ordering.first == expectation
end

#register(expectation) ⇒ Object



9
10
11
# File 'lib/gems/rspec-1.1.12/lib/spec/mocks/order_group.rb', line 9

def register(expectation)
  @ordering << expectation
end