Class: Crspec::Matchers::RespondToMatcher
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- Crspec::Matchers::RespondToMatcher
- Defined in:
- lib/crspec/matchers.rb
Instance Attribute Summary
Attributes inherited from BaseMatcher
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(*methods) ⇒ RespondToMatcher
constructor
A new instance of RespondToMatcher.
- #matches?(actual) ⇒ Boolean
Methods inherited from BaseMatcher
#and, #failure_message_when_negated, #or
Constructor Details
#initialize(*methods) ⇒ RespondToMatcher
Returns a new instance of RespondToMatcher.
236 237 238 239 |
# File 'lib/crspec/matchers.rb', line 236 def initialize(*methods) super(methods) @methods = methods end |
Instance Method Details
#failure_message ⇒ Object
246 247 248 |
# File 'lib/crspec/matchers.rb', line 246 def "Expected #{@actual.inspect} to respond to #{@methods.map(&:inspect).join(", ")}" end |
#matches?(actual) ⇒ Boolean
241 242 243 244 |
# File 'lib/crspec/matchers.rb', line 241 def matches?(actual) @actual = actual @methods.all? { |m| @actual.respond_to?(m) } end |