class RSpec::Mocks::ProxyForNil

@private

Attributes

warn_about_expectations[RW]
warn_about_expectations?[RW]

Public Class Methods

new() click to toggle source
Calls superclass method RSpec::Mocks::Proxy::new
# File lib/rspec/mocks/proxy_for_nil.rb, line 6
def initialize
  @warn_about_expectations = true
  super nil
end

Public Instance Methods

add_message_expectation(location, method_name, opts={}, &block) click to toggle source
# File lib/rspec/mocks/proxy_for_nil.rb, line 13
def add_message_expectation(location, method_name, opts={}, &block)
  warn(method_name) if warn_about_expectations?
  super
end
add_negative_message_expectation(location, method_name, &implementation) click to toggle source
Calls superclass method
# File lib/rspec/mocks/proxy_for_nil.rb, line 18
def add_negative_message_expectation(location, method_name, &implementation)
  warn(method_name) if warn_about_expectations?
  super
end
add_stub(location, method_name, opts={}, &implementation) click to toggle source
Calls superclass method RSpec::Mocks::Proxy#add_stub
# File lib/rspec/mocks/proxy_for_nil.rb, line 23
def add_stub(location, method_name, opts={}, &implementation)
  warn(method_name) if warn_about_expectations?
  super
end

Private Instance Methods

warn(method_name) click to toggle source
# File lib/rspec/mocks/proxy_for_nil.rb, line 30
def warn method_name
  non_rspec_caller = caller.find { |line| !line.include?('lib/rspec/mocks') }
  Kernel.warn("An expectation of :#{method_name} was set on nil. Called from #{non_rspec_caller}. Use allow_message_expectations_on_nil to disable warnings.")
end