Class: RSpec::Matchers::BuiltIn::RespondTo Private
- Inherits:
- 
      BaseMatcher
        - Object
- BaseMatcher
- RSpec::Matchers::BuiltIn::RespondTo
 
- Defined in:
- lib/rspec/matchers/built_in/respond_to.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides the implementation for respond_to.
Not intended to be instantiated directly.
Constant Summary
Constant Summary
Constants inherited from BaseMatcher
Instance Method Summary (collapse)
- 
  
      - (Object) argument 
      (also: #arguments)
  
    No-op. 
- - (String) description private
- - (String) failure_message private
- - (String) failure_message_when_negated private
- 
  
      - (RespondTo) initialize(*names) 
  
    constructor
  private
    A new instance of RespondTo. 
- 
  
      - (Object) with(n) 
  
    Specifies the number of expected arguments. 
- 
  
      - (Object) with_any_keywords 
      (also: #and_any_keywords)
  
    Specifies that the method accepts any keyword, i.e. 
- 
  
      - (Object) with_keywords(*keywords) 
      (also: #and_keywords)
  
    Specifies keyword arguments, if any. 
- 
  
      - (Object) with_unlimited_arguments 
      (also: #and_unlimited_arguments)
  
    Specifies that the number of arguments has no upper limit, i.e. 
Methods inherited from BaseMatcher
#diffable?, #expects_call_stack_jump?, #match_unless_raises, #supports_block_expectations?
Methods included from Composable
#===, #and, #description_of, #or, should_enumerate?, surface_descriptions_in, unreadable_io?, #values_match?
Constructor Details
- (RespondTo) initialize(*names)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RespondTo
| 10 11 12 13 14 15 16 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 10 def initialize(*names) @names = names @expected_arity = nil @expected_keywords = [] @unlimited_arguments = nil @arbitrary_keywords = nil end | 
Instance Method Details
- (Object) argument Also known as: arguments
No-op. Intended to be used as syntactic sugar when using with.
| 70 71 72 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 70 def argument self end | 
- (String) description
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 99 100 101 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 99 def description "respond to #{pp_names}#{with_arity}" end | 
- (String) failure_message
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 87 88 89 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 87 def "expected #{actual_formatted} to respond to #{@failing_method_names.map { |name| description_of(name) }.join(', ')}#{with_arity}" end | 
- (String) failure_message_when_negated
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 93 94 95 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 93 def .sub(/to respond to/, 'not to respond to') end | 
- (Object) with(n)
Specifies the number of expected arguments.
| 23 24 25 26 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 23 def with(n) @expected_arity = n self end | 
- (Object) with_any_keywords Also known as: and_any_keywords
Specifies that the method accepts any keyword, i.e. the method has a splatted keyword parameter of the form **kw_args.
| 47 48 49 50 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 47 def with_any_keywords @arbitrary_keywords = true self end | 
- (Object) with_keywords(*keywords) Also known as: and_keywords
Specifies keyword arguments, if any.
| 35 36 37 38 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 35 def with_keywords(*keywords) @expected_keywords = keywords self end | 
- (Object) with_unlimited_arguments Also known as: and_unlimited_arguments
Specifies that the number of arguments has no upper limit, i.e. the method has a splatted parameter of the form *args.
| 59 60 61 62 | # File 'lib/rspec/matchers/built_in/respond_to.rb', line 59 def with_unlimited_arguments @unlimited_arguments = true self end |