Class: RSpec::Mocks::Matchers::HaveReceived Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Matcher
|
|
Inherits: | Object |
Defined in: | rspec-mocks/lib/rspec/mocks/matchers/have_received.rb |
Constant Summary
-
ARGS_CONSTRAINTS =
# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 9%w[with]
-
CONSTRAINTS =
# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 10COUNT_CONSTRAINTS + ARGS_CONSTRAINTS + %w[ordered]
-
COUNT_CONSTRAINTS =
# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 8%w[exactly at_least at_most times time once twice thrice]
Class Method Summary
- .new(method_name, &block) ⇒ HaveReceived constructor Internal use only
Instance Attribute Summary
- #expected_messages_received_in_order? ⇒ Boolean readonly private Internal use only
Instance Method Summary
- #description Internal use only
- #does_not_match?(subject) ⇒ Boolean Internal use only
- #failure_message Internal use only
- #failure_message_when_negated Internal use only
- #matcher_name Internal use only
- #matches?(subject, &block) ⇒ Boolean Internal use only
- #setup_allowance(_subject, &_block) Internal use only
- #setup_any_instance_allowance(_subject, &_block) Internal use only
- #setup_any_instance_expectation(_subject, &_block) Internal use only
- #setup_any_instance_negative_expectation(_subject, &_block) Internal use only
- #setup_expectation(subject, &block) Internal use only
- #setup_negative_expectation(subject, &block) Internal use only
- #apply_constraints_to(expectation) private Internal use only
- #capture_failure_message private Internal use only
- #count_constraint private Internal use only
- #disallow(type, reason = "") private Internal use only
- #ensure_count_unconstrained private Internal use only
- #expect private Internal use only
- #mock_proxy private Internal use only
- #notify_failure_message private Internal use only
Instance Attribute Details
#expected_messages_received_in_order? ⇒ Boolean
(readonly, private)
# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 123
def mock_proxy. @expectation, &@block @expectation. && @expectation.ensure_expected_ordering_received! end
Instance Method Details
#apply_constraints_to(expectation) (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 95
def apply_constraints_to(expectation) @constraints.each do |constraint| expectation.send(*constraint) end end
#capture_failure_message (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 112
def RSpec::Support.with_failure_notifier(Proc.new { |err, _opt| return err. }) do end end
#count_constraint (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 106
def count_constraint @constraints.map(&:first).find do |constraint| COUNT_CONSTRAINTS.include?(constraint) end end
#description
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 48
def description (@expectation ||= expect).description_for("have received") end
#disallow(type, reason = "") (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 85
def disallow(type, reason="") RSpec::Mocks.error_generator.raise_have_received_disallowed(type, reason) end
#does_not_match?(subject) ⇒ Boolean
# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 32
def does_not_match?(subject) @subject = subject ensure_count_unconstrained @expectation = expect.never mock_proxy.ensure_implemented(@method_name) end
#ensure_count_unconstrained (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 101
def ensure_count_unconstrained return unless count_constraint RSpec::Mocks.error_generator.raise_cant_constrain_count_for_negated_have_received_error(count_constraint) end
#expect (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 89
def expect expectation = mock_proxy.build_expectation(@method_name) apply_constraints_to expectation expectation end
#failure_message
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 40
def end
#failure_message_when_negated
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 44
def end
#matcher_name
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 19
def matcher_name "have_received" end
#matches?(subject, &block) ⇒ Boolean
# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 23
def matches?(subject, &block) @block ||= block @subject = subject @expectation = expect mock_proxy.ensure_implemented(@method_name) end
#mock_proxy (private)
[ GitHub ]#notify_failure_message (private)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 118
def mock_proxy.check_for_unexpected_arguments(@expectation) @expectation.generate_error end
#setup_allowance(_subject, &_block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 67
def setup_allowance(_subject, &_block) disallow("allow", " as it would have no effect") end
#setup_any_instance_allowance(_subject, &_block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 71
def setup_any_instance_allowance(_subject, &_block) disallow("allow_any_instance_of") end
#setup_any_instance_expectation(_subject, &_block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 75
def setup_any_instance_expectation(_subject, &_block) disallow("expect_any_instance_of") end
#setup_any_instance_negative_expectation(_subject, &_block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 79
def setup_any_instance_negative_expectation(_subject, &_block) disallow("expect_any_instance_of") end
#setup_expectation(subject, &block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 59
def setup_expectation(subject, &block) unless matches?(subject, &block) end
#setup_negative_expectation(subject, &block)
[ GitHub ]# File 'rspec-mocks/lib/rspec/mocks/matchers/have_received.rb', line 63
def setup_negative_expectation(subject, &block) unless does_not_match?(subject, &block) end