Class: RSpec::Mocks::OrderGroup Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rspec-mocks/lib/rspec/mocks/order_group.rb |
Class Method Summary
- .new ⇒ OrderGroup constructor Internal use only
Instance Attribute Summary
- #empty? ⇒ Boolean readonly Internal use only
- #expectations_invoked_in_order? ⇒ Boolean readonly private Internal use only
Instance Method Summary
- #clear Internal use only
- #consume Internal use only
- #handle_order_constraint(expectation) Internal use only
- #invoked(message) Internal use only
- #ready_for?(expectation) ⇒ Boolean Internal use only
- #register(expectation) Internal use only
- #verify_invocation_order(expectation) Internal use only
- #expectation_for(message) private Internal use only
- #expected_invocations private Internal use only
- #invoked_expectations private Internal use only
- #remaining_expectations private Internal use only
Instance Attribute Details
#empty? ⇒ Boolean
(readonly)
# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 54
def empty? @expectations.empty? end
#expectations_invoked_in_order? ⇒ Boolean
(readonly, private)
# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 64
def expectations_invoked_in_order? invoked_expectations == expected_invocations end
Instance Method Details
#clear
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 48
def clear @index = 0 @invocation_order.clear @expectations.clear end
#consume
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 26
def consume remaining_expectations.each_with_index do |expectation, index| next unless expectation.ordered? @index += index + 1 return expectation end nil end
#expectation_for(message) (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 76
def expectation_for( ) @expectations.find { |e| == e } end
#expected_invocations (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 72
def expected_invocations @invocation_order.map { |invocation| expectation_for(invocation) }.compact end
#handle_order_constraint(expectation)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 37
def handle_order_constraint(expectation) return unless expectation.ordered? && remaining_expectations.include?(expectation) return consume if ready_for?(expectation) expectation.raise_out_of_order_error end
#invoked(message)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 16
def invoked( ) @invocation_order << end
#invoked_expectations (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 68
def invoked_expectations @expectations.select { |e| e.ordered? && @invocation_order.include?(e) } end
#ready_for?(expectation) ⇒ Boolean
# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 21
def ready_for?(expectation) remaining_expectations.find(&:ordered?) == expectation end
#register(expectation)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 12
def register(expectation) @expectations << expectation end
#remaining_expectations (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 60
def remaining_expectations @expectations[@index..-1] || [] end
#verify_invocation_order(expectation)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/order_group.rb', line 43
def verify_invocation_order(expectation) expectation.raise_out_of_order_error unless expectations_invoked_in_order? true end