Class: RSpec::Mocks::Matchers::ReceiveMessages
- Includes:
- Matcher
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(message_return_value_hash) ⇒ ReceiveMessages
constructor
A new instance of ReceiveMessages.
- #matcher_name ⇒ Object
- #setup_allowance(subject) ⇒ Object
- #setup_any_instance_allowance(subject) ⇒ Object
- #setup_any_instance_expectation(subject) ⇒ Object
- #setup_expectation(subject) ⇒ Object (also: #matches?)
- #setup_negative_expectation(_subject) ⇒ Object (also: #does_not_match?)
- #warn_about_block ⇒ Object
Constructor Details
#initialize(message_return_value_hash) ⇒ ReceiveMessages
Returns a new instance of ReceiveMessages.
8 9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 8 def initialize() @message_return_value_hash = @backtrace_line = CallerFilter.first_non_rspec_line end |
Instance Method Details
#description ⇒ Object
17 18 19 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 17 def description "receive messages: #{@message_return_value_hash.inspect}" end |
#matcher_name ⇒ Object
13 14 15 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 13 def matcher_name "receive_messages" end |
#setup_allowance(subject) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 36 def setup_allowance(subject) warn_about_block if block_given? (proxy_on(subject)) do |host, , return_value| host.add_simple_stub(, return_value) end end |
#setup_any_instance_allowance(subject) ⇒ Object
50 51 52 53 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 50 def setup_any_instance_allowance(subject) warn_about_block if block_given? any_instance_of(subject).stub(@message_return_value_hash) end |
#setup_any_instance_expectation(subject) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 43 def setup_any_instance_expectation(subject) warn_about_block if block_given? (any_instance_of(subject)) do |host, , return_value| host.should_receive().and_return(return_value) end end |
#setup_expectation(subject) ⇒ Object Also known as: matches?
21 22 23 24 25 26 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 21 def setup_expectation(subject) warn_about_block if block_given? (proxy_on(subject)) do |host, , return_value| host.add_simple_expectation(, return_value, @backtrace_line) end end |
#setup_negative_expectation(_subject) ⇒ Object Also known as: does_not_match?
29 30 31 32 33 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 29 def setup_negative_expectation(_subject) raise NegationUnsupportedError, "`expect(...).to_not receive_messages` is not supported since it " \ "doesn't really make sense. What would it even mean?" end |
#warn_about_block ⇒ Object
55 56 57 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive_messages.rb', line 55 def warn_about_block raise "Implementation blocks aren't supported with `receive_messages`" end |