Class: Spec::Matchers::RespondTo

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/matchers/respond_to.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(sym) ⇒ RespondTo

Returns a new instance of RespondTo.



5
6
7
# File 'lib/spec/matchers/respond_to.rb', line 5

def initialize(sym)
  @sym = sym
end

Instance Method Details

#descriptionObject



21
22
23
# File 'lib/spec/matchers/respond_to.rb', line 21

def description
  "respond to ##{@sym.to_s}"
end

#failure_messageObject



13
14
15
# File 'lib/spec/matchers/respond_to.rb', line 13

def failure_message
  "expected target to respond to #{@sym.inspect}"
end

#matches?(target) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/spec/matchers/respond_to.rb', line 9

def matches?(target)
  return target.respond_to?(@sym)
end

#negative_failure_messageObject



17
18
19
# File 'lib/spec/matchers/respond_to.rb', line 17

def negative_failure_message
  "expected target not to respond to #{@sym.inspect}"
end