Class: Spec::Matchers::RespondTo
- Defined in:
- lib/spec/matchers/respond_to.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(*names) ⇒ RespondTo
constructor
A new instance of RespondTo.
- #matches?(target) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(*names) ⇒ RespondTo
Returns a new instance of RespondTo.
5 6 7 8 |
# File 'lib/spec/matchers/respond_to.rb', line 5 def initialize(*names) @names = names @names_not_responded_to = [] end |
Instance Method Details
#description ⇒ Object
27 28 29 |
# File 'lib/spec/matchers/respond_to.rb', line 27 def description "respond to ##{@names.to_s}" end |
#failure_message ⇒ Object
19 20 21 |
# File 'lib/spec/matchers/respond_to.rb', line 19 def "expected target to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}" end |
#matches?(target) ⇒ Boolean
10 11 12 13 14 15 16 17 |
# File 'lib/spec/matchers/respond_to.rb', line 10 def matches?(target) @names.each do |name| unless target.respond_to?(name) @names_not_responded_to << name end end return @names_not_responded_to.empty? end |
#negative_failure_message ⇒ Object
23 24 25 |
# File 'lib/spec/matchers/respond_to.rb', line 23 def "expected target not to respond to #{@names.collect {|name| name.inspect }.join(', ')}" end |