123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Mocks::ProxyForNil Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: RSpec::Mocks::PartialDoubleProxy
Defined in: rspec-mocks/lib/rspec/mocks/proxy.rb

Constant Summary

Proxy - Inherited

DEFAULT_MESSAGE_EXPECTATION_OPTS

Class Method Summary

Proxy - Inherited

Instance Attribute Summary

Proxy - Inherited

Instance Method Summary

Instance Attribute Details

#disallow_expectations (rw)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 470

attr_accessor :disallow_expectations

#warn_about_expectations (rw)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 471

attr_accessor :warn_about_expectations

Instance Method Details

#add_message_expectation(method_name, opts = {}, &block)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 473

def add_message_expectation(method_name, opts={}, &block)
  warn_or_raise!(method_name)
  super
end

#add_stub(method_name, opts = {}, &implementation)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 478

def add_stub(method_name, opts={}, &implementation)
  warn_or_raise!(method_name)
  super
end

#raise_error(method_name) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 515

def raise_error(method_name)
  @error_generator.raise_expectation_on_nil_error(method_name)
end

#set_expectation_behavior (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 485

def set_expectation_behavior
  case RSpec::Mocks.configuration.allow_message_expectations_on_nil
  when false
    @warn_about_expectations = false
    @disallow_expectations = true
  when true
    @warn_about_expectations = false
    @disallow_expectations = false
  else
    @warn_about_expectations = true
    @disallow_expectations = false
  end
end

#warn(method_name) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 510

def warn(method_name)
  warning_msg = @error_generator.expectation_on_nil_message(method_name)
  RSpec.warning(warning_msg)
end

#warn_or_raise!(method_name) (private)

[ GitHub ]

  
# File 'rspec-mocks/lib/rspec/mocks/proxy.rb', line 499

def warn_or_raise!(method_name)
  # This method intentionally swallows the message when
  # neither disallow_expectations nor warn_about_expectations
  # are set to true.
  if disallow_expectations
    raise_error(method_name)
  elsif warn_about_expectations
    warn(method_name)
  end
end