Parent

Included Modules

Class/Module Index [+]

Quicksearch

RSpec::Matchers::BuiltIn::RespondTo

@api private Provides the implementation for `respond_to`. Not intended to be instantiated directly.

Public Class Methods

new(*names) click to toggle source
# File lib/rspec/matchers/built_in/respond_to.rb, line 12
def initialize(*names)
  @names = names
  @expected_arity = nil
end

Public Instance Methods

argument() click to toggle source

@api public No-op. Intended to be used as syntactic sugar when using `with`.

@example

expect(obj).to respond_to(:message).with(3).arguments
# File lib/rspec/matchers/built_in/respond_to.rb, line 32
def argument
  self
end
Also aliased as: arguments
arguments() click to toggle source
Alias for: argument
description() click to toggle source

@api private @return [String]

# File lib/rspec/matchers/built_in/respond_to.rb, line 61
def description
  "respond to #{pp_names}#{with_arity}"
end
does_not_match?(actual) click to toggle source

@private

# File lib/rspec/matchers/built_in/respond_to.rb, line 43
def does_not_match?(actual)
  find_failing_method_names(actual, :select).empty?
end
failure_message() click to toggle source

@api private @return [String]

# File lib/rspec/matchers/built_in/respond_to.rb, line 49
def failure_message
  "expected #{@actual.inspect} to respond to #{@failing_method_names.map { |name| name.inspect }.join(', ')}#{with_arity}"
end
failure_message_when_negated() click to toggle source

@api private @return [String]

# File lib/rspec/matchers/built_in/respond_to.rb, line 55
def failure_message_when_negated
  failure_message.sub(/to respond to/, 'not to respond to')
end
matches?(actual) click to toggle source

@private

# File lib/rspec/matchers/built_in/respond_to.rb, line 38
def matches?(actual)
  find_failing_method_names(actual, :reject).empty?
end
supports_block_expectations?() click to toggle source

@private

# File lib/rspec/matchers/built_in/respond_to.rb, line 66
def supports_block_expectations?
  false
end
with(n) click to toggle source

@api public Specifies the number of expected arguments.

@example

expect(obj).to respond_to(:message).with(3).arguments
# File lib/rspec/matchers/built_in/respond_to.rb, line 22
def with(n)
  @expected_arity = n
  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.