Class: RSpec::Matchers::BuiltIn::RespondTo

### Home Classes Methods

### In Files

- lib/rspec/matchers/built_in/respond_to.rb

### Parent

RSpec::Matchers::BuiltIn::BaseMatcher

### Methods

- ::new
- #argument
- #arguments
- #description
- #does_not_match?
- #failure_message
- #failure_message_when_negated
- #matches?
- #with

### Class/Module Index

Quicksearch

- RSpec
- RSpec::Expectations
- RSpec::Expectations::BlockExpectationTarget
- RSpec::Expectations::Configuration
- RSpec::Expectations::ExpectationHelper
- RSpec::Expectations::ExpectationNotMetError
- RSpec::Expectations::ExpectationTarget
- RSpec::Expectations::LegacyMacherAdapter
- RSpec::Expectations::LegacyMatcherAdapter
- RSpec::Expectations::LegacyMatcherAdapter::RSpec1
- RSpec::Expectations::LegacyMatcherAdapter::RSpec2
- RSpec::Expectations::NegativeExpectationHandler
- RSpec::Expectations::PositiveExpectationHandler
- RSpec::Expectations::Syntax
- RSpec::Expectations::Version
- RSpec::Matchers
- RSpec::Matchers::AliasedMatcher
- RSpec::Matchers::AliasedMatcherWithOperatorSupport
- RSpec::Matchers::AliasedNegatedMatcher
- RSpec::Matchers::BuiltIn
- RSpec::Matchers::BuiltIn::All
- RSpec::Matchers::BuiltIn::BaseMatcher
- RSpec::Matchers::BuiltIn::BaseMatcher::DefaultFailureMessages
- RSpec::Matchers::BuiltIn::Be
- RSpec::Matchers::BuiltIn::BeAKindOf
- RSpec::Matchers::BuiltIn::BeAnInstanceOf
- RSpec::Matchers::BuiltIn::BeBetween
- RSpec::Matchers::BuiltIn::BeComparedTo
- RSpec::Matchers::BuiltIn::BeFalsey
- RSpec::Matchers::BuiltIn::BeHelpers
- RSpec::Matchers::BuiltIn::BeNil
- RSpec::Matchers::BuiltIn::BePredicate
- RSpec::Matchers::BuiltIn::BeTruthy
- RSpec::Matchers::BuiltIn::BeWithin
- RSpec::Matchers::BuiltIn::CaptureStderr
- RSpec::Matchers::BuiltIn::CaptureStdout
- RSpec::Matchers::BuiltIn::CaptureStreamToTempfile
- RSpec::Matchers::BuiltIn::Change
- RSpec::Matchers::BuiltIn::ChangeDetails
- RSpec::Matchers::BuiltIn::ChangeFromValue
- RSpec::Matchers::BuiltIn::ChangeRelatively
- RSpec::Matchers::BuiltIn::ChangeToValue
- RSpec::Matchers::BuiltIn::Compound
- RSpec::Matchers::BuiltIn::Compound::And
- RSpec::Matchers::BuiltIn::Compound::NestedEvaluator
- RSpec::Matchers::BuiltIn::Compound::Or
- RSpec::Matchers::BuiltIn::Compound::SequentialEvaluator
- RSpec::Matchers::BuiltIn::ContainExactly
- RSpec::Matchers::BuiltIn::ContainExactly::PairingsMaximizer
- RSpec::Matchers::BuiltIn::Cover
- RSpec::Matchers::BuiltIn::EndWith
- RSpec::Matchers::BuiltIn::Eq
- RSpec::Matchers::BuiltIn::Eql
- RSpec::Matchers::BuiltIn::Equal
- RSpec::Matchers::BuiltIn::Exist
- RSpec::Matchers::BuiltIn::Exist::ExistenceTest
- RSpec::Matchers::BuiltIn::Has
- RSpec::Matchers::BuiltIn::HaveAttributes
- RSpec::Matchers::BuiltIn::Include
- RSpec::Matchers::BuiltIn::Match
- RSpec::Matchers::BuiltIn::NegativeOperatorMatcher
- RSpec::Matchers::BuiltIn::NullCapture
- RSpec::Matchers::BuiltIn::OperatorMatcher
- RSpec::Matchers::BuiltIn::Output
- RSpec::Matchers::BuiltIn::PositiveOperatorMatcher
- RSpec::Matchers::BuiltIn::RaiseError
- RSpec::Matchers::BuiltIn::RespondTo
- RSpec::Matchers::BuiltIn::Satisfy
- RSpec::Matchers::BuiltIn::SpecificValuesChange
- RSpec::Matchers::BuiltIn::StartAndEndWith
- RSpec::Matchers::BuiltIn::StartOrEndWith
- RSpec::Matchers::BuiltIn::StartWith
- RSpec::Matchers::BuiltIn::ThrowSymbol
- RSpec::Matchers::BuiltIn::YieldControl
- RSpec::Matchers::BuiltIn::YieldProbe
- RSpec::Matchers::BuiltIn::YieldSuccessiveArgs
- RSpec::Matchers::BuiltIn::YieldWithArgs
- RSpec::Matchers::BuiltIn::YieldWithNoArgs
- RSpec::Matchers::Composable
- RSpec::Matchers::DSL
- RSpec::Matchers::DSL::DefaultImplementations
- RSpec::Matchers::DSL::Macros
- RSpec::Matchers::DSL::Macros::Deprecated
- RSpec::Matchers::DSL::Matcher
- RSpec::Matchers::ExpectedsForMultipleDiffs
- RSpec::Matchers::MatcherDelegator
- RSpec::Matchers::MatcherProtocol
- RSpec::Matchers::Pretty
- BasicObject
- Object

No matching classes.

# 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 10
    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 30
    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 59
    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 41
    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 47
    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 53
    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 36
    def matches?(actual)
      find_failing_method_names(actual, :reject).empty?
    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 20
    def with(n)
      @expected_arity = n
      self
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.