Class: RSpec::Mocks::AnyInstance::MessageChains Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb |
Class Method Summary
- .new ⇒ MessageChains constructor Internal use only
Instance Attribute Summary
- #all_expectations_fulfilled? ⇒ Boolean readonly Internal use only
Instance Method Summary
- #[](method_name) Internal use only
- #add(method_name, chain) Internal use only
- #each_unfulfilled_expectation_matching(method_name, *args) Internal use only
- #has_expectation?(method_name) ⇒ Boolean Internal use only
- #playback!(instance, method_name) Internal use only
- #received_expected_message!(method_name) Internal use only
- #remove_stub_chains_for!(method_name) Internal use only
- #unfulfilled_expectations Internal use only
- #raise_if_second_instance_to_receive_message(instance) private Internal use only
Instance Attribute Details
#all_expectations_fulfilled? ⇒ Boolean
(readonly)
# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 43
def all_expectations_fulfilled? @chains_by_method_name.all? do |_method_name, chains| chains.all? { |chain| chain.expectation_fulfilled? } end end
Instance Method Details
#[](method_name)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 11
def [](method_name) @chains_by_method_name[method_name] end
#add(method_name, chain)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 16
def add(method_name, chain) @chains_by_method_name[method_name] << chain chain end
#each_unfulfilled_expectation_matching(method_name, *args)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 36
def each_unfulfilled_expectation_matching(method_name, *args) @chains_by_method_name[method_name].each do |chain| yield chain if !chain.expectation_fulfilled? && chain.matches_args?(*args) end end
#has_expectation?(method_name) ⇒ Boolean
# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 29
def has_expectation?(method_name) @chains_by_method_name[method_name].find do |chain| ExpectationChain === chain end end
#playback!(instance, method_name)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 64
def playback!(instance, method_name) (instance) @chains_by_method_name[method_name].each do |chain| chain.playback!(instance) end end
#raise_if_second_instance_to_receive_message(instance) (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 73
def (instance) @instance_with_expectation ||= instance if ExpectationChain === instance return unless ExpectationChain === instance return if @instance_with_expectation.equal?(instance) AnyInstance.error_generator. (unfulfilled_expectations) end
#received_expected_message!(method_name)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 57
def (method_name) @chains_by_method_name[method_name].each do |chain| chain.expectation_fulfilled! end end
#remove_stub_chains_for!(method_name)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 22
def remove_stub_chains_for!(method_name) @chains_by_method_name[method_name].reject! do |chain| StubChain === chain end end
#unfulfilled_expectations
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/any_instance/message_chains.rb', line 50
def unfulfilled_expectations @chains_by_method_name.map do |method_name, chains| method_name.to_s if ExpectationChain === chains.last && !chains.last.expectation_fulfilled? end.compact end