Class: Minicrest::InstanceOf
- Defined in:
- lib/minicrest/value_matchers.rb
Overview
Matcher that checks for exact class membership.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message(actual) ⇒ Object
-
#initialize(expected_type) ⇒ InstanceOf
constructor
A new instance of InstanceOf.
- #matches?(actual) ⇒ Boolean
- #negated_failure_message(actual) ⇒ Object
Methods inherited from Matcher
Constructor Details
#initialize(expected_type) ⇒ InstanceOf
Returns a new instance of InstanceOf.
65 66 67 68 |
# File 'lib/minicrest/value_matchers.rb', line 65 def initialize(expected_type) super() @expected_type = expected_type end |
Instance Method Details
#description ⇒ Object
74 75 76 |
# File 'lib/minicrest/value_matchers.rb', line 74 def description "an instance of #{@expected_type}" end |
#failure_message(actual) ⇒ Object
78 79 80 |
# File 'lib/minicrest/value_matchers.rb', line 78 def (actual) "expected #{actual.inspect} to be an instance of #{@expected_type}, but was a #{actual.class}" end |
#matches?(actual) ⇒ Boolean
70 71 72 |
# File 'lib/minicrest/value_matchers.rb', line 70 def matches?(actual) actual.instance_of?(@expected_type) end |
#negated_failure_message(actual) ⇒ Object
82 83 84 |
# File 'lib/minicrest/value_matchers.rb', line 82 def (actual) "expected #{actual.inspect} not to be an instance of #{@expected_type}, but it was" end |