Class: RSpec::Mocks::Matchers::HaveReceived
- Includes:
- Matcher
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb
Constant Summary collapse
- COUNT_CONSTRAINTS =
%w[exactly at_least at_most times time once twice thrice]
- ARGS_CONSTRAINTS =
%w[with]
- CONSTRAINTS =
COUNT_CONSTRAINTS + ARGS_CONSTRAINTS + %w[ordered]
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(subject) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(method_name, &block) ⇒ HaveReceived
constructor
A new instance of HaveReceived.
- #matcher_name ⇒ Object
- #matches?(subject, &block) ⇒ Boolean
- #setup_allowance(_subject, &_block) ⇒ Object
- #setup_any_instance_allowance(_subject, &_block) ⇒ Object
- #setup_any_instance_expectation(_subject, &_block) ⇒ Object
- #setup_any_instance_negative_expectation(_subject, &_block) ⇒ Object
- #setup_expectation(subject, &block) ⇒ Object
- #setup_negative_expectation(subject, &block) ⇒ Object
Constructor Details
#initialize(method_name, &block) ⇒ HaveReceived
Returns a new instance of HaveReceived.
12 13 14 15 16 17 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 12 def initialize(method_name, &block) @method_name = method_name @block = block @constraints = [] @subject = nil end |
Instance Method Details
#description ⇒ Object
48 49 50 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 48 def description (@expectation ||= expect).description_for("have received") end |
#does_not_match?(subject) ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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 |
#failure_message ⇒ Object
40 41 42 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 40 def end |
#failure_message_when_negated ⇒ Object
44 45 46 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 44 def end |
#matcher_name ⇒ Object
19 20 21 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 19 def matcher_name "have_received" end |
#matches?(subject, &block) ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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 |
#setup_allowance(_subject, &_block) ⇒ Object
67 68 69 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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) ⇒ Object
71 72 73 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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) ⇒ Object
75 76 77 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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) ⇒ Object
79 80 81 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/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) ⇒ Object
59 60 61 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 59 def setup_expectation(subject, &block) unless matches?(subject, &block) end |
#setup_negative_expectation(subject, &block) ⇒ Object
63 64 65 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/have_received.rb', line 63 def setup_negative_expectation(subject, &block) unless does_not_match?(subject, &block) end |