Class: Micronaut::Matchers::RespondTo
- Defined in:
- lib/micronaut/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?(given) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(*names) ⇒ RespondTo
Returns a new instance of RespondTo.
6 7 8 9 |
# File 'lib/micronaut/matchers/respond_to.rb', line 6 def initialize(*names) @names = names @names_not_responded_to = [] end |
Instance Method Details
#description ⇒ Object
29 30 31 32 |
# File 'lib/micronaut/matchers/respond_to.rb', line 29 def description # Ruby 1.9 returns the same thing for array.to_s as array.inspect, so just use array.inspect here "respond to #{@names.inspect}" end |
#failure_message ⇒ Object
21 22 23 |
# File 'lib/micronaut/matchers/respond_to.rb', line 21 def "expected #{@given.inspect} to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}" end |
#matches?(given) ⇒ Boolean
11 12 13 14 15 16 17 18 19 |
# File 'lib/micronaut/matchers/respond_to.rb', line 11 def matches?(given) @given = given @names.each do |name| unless given.respond_to?(name) @names_not_responded_to << name end end @names_not_responded_to.empty? end |
#negative_failure_message ⇒ Object
25 26 27 |
# File 'lib/micronaut/matchers/respond_to.rb', line 25 def "expected #{@given.inspect} not to respond to #{@names.collect {|name| name.inspect }.join(', ')}" end |