Class: RSpec::Mocks::SimpleMessageExpectation

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb

Overview

A message expectation that only allows concrete return values to be set for a message. While this same effect can be achieved using a standard MessageExpectation, this version is much faster and so can be used as an optimization.

Instance Method Summary collapse

Constructor Details

#initialize(message, response, error_generator, backtrace_line = nil) ⇒ SimpleMessageExpectation

Returns a new instance of SimpleMessageExpectation.



12
13
14
15
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 12

def initialize(message, response, error_generator, backtrace_line=nil)
  @message, @response, @error_generator, @backtrace_line = message.to_sym, response, error_generator, backtrace_line
  @received = false
end

Instance Method Details

#called_max_times?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 26

def called_max_times?
  false
end

#invoke(*_) ⇒ Object



17
18
19
20
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 17

def invoke(*_)
  @received = true
  @response
end

#matches?(message, *_) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 22

def matches?(message, *_)
  @message == message.to_sym
end

#unadvise(_) ⇒ Object



37
38
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 37

def unadvise(_)
end

#verify_messages_receivedObject



30
31
32
33
34
35
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/message_expectation.rb', line 30

def verify_messages_received
  return if @received
  @error_generator.raise_expectation_error(
    @message, 1, ArgumentListMatcher::MATCH_ALL, 0, nil, [], @backtrace_line
  )
end