Class: RSpec::Mocks::Matchers::Receive

Inherits:
Object
  • Object
show all
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.rb

Defined Under Namespace

Classes: DefaultDescribable

Instance Method Summary collapse

Constructor Details

#initialize(message, block) ⇒ Receive

Returns a new instance of Receive.



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

def initialize(message, block)
  @message                 = message
  @block                   = block
  @recorded_customizations = []
end

Instance Method Details

#descriptionObject



20
21
22
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive.rb', line 20

def description
  describable.description_for("receive")
end

#matcher_nameObject



16
17
18
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive.rb', line 16

def matcher_name
  "receive"
end

#setup_allowance(subject, &block) ⇒ Object



41
42
43
44
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive.rb', line 41

def setup_allowance(subject, &block)
  warn_if_any_instance("allow", subject)
  setup_mock_proxy_method_substitute(subject, :add_stub, block)
end

#setup_any_instance_allowance(subject, &block) ⇒ Object



54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive.rb', line 54

def setup_any_instance_allowance(subject, &block)
  setup_any_instance_method_substitute(subject, :stub, block)
end

#setup_any_instance_expectation(subject, &block) ⇒ Object



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.rb', line 46

def setup_any_instance_expectation(subject, &block)
  setup_any_instance_method_substitute(subject, :should_receive, block)
end

#setup_any_instance_negative_expectation(subject, &block) ⇒ Object



50
51
52
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive.rb', line 50

def setup_any_instance_negative_expectation(subject, &block)
  setup_any_instance_method_substitute(subject, :should_not_receive, block)
end

#setup_expectation(subject, &block) ⇒ Object Also known as: matches?



24
25
26
27
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.2/lib/rspec/mocks/matchers/receive.rb', line 24

def setup_expectation(subject, &block)
  warn_if_any_instance("expect", subject)
  @describable = setup_mock_proxy_method_substitute(subject, :add_message_expectation, block)
end

#setup_negative_expectation(subject, &block) ⇒ Object Also known as: does_not_match?



30
31
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/receive.rb', line 30

def setup_negative_expectation(subject, &block)
  # ensure `never` goes first for cases like `never.and_return(5)`,
  # where `and_return` is meant to raise an error
  @recorded_customizations.unshift ExpectationCustomization.new(:never, [], nil)

  warn_if_any_instance("expect", subject)

  setup_expectation(subject, &block)
end