Class: Expected::Matchers::InheritFromMatcher
- Inherits:
-
Object
- Object
- Expected::Matchers::InheritFromMatcher
- Defined in:
- lib/expected/matchers/inherit_from.rb
Overview
Class used by #inherit_from
Instance Attribute Summary collapse
-
#expected_ancestor ⇒ Object
readonly
Returns the value of attribute expected_ancestor.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #description ⇒ String
- #failure_message ⇒ String
- #failure_message_when_negated ⇒ String
-
#initialize(expected_ancestor) ⇒ InheritFromMatcher
constructor
A new instance of InheritFromMatcher.
-
#matches?(subject) ⇒ True, False
Run the test.
Constructor Details
#initialize(expected_ancestor) ⇒ InheritFromMatcher
Returns a new instance of InheritFromMatcher.
23 24 25 |
# File 'lib/expected/matchers/inherit_from.rb', line 23 def initialize(expected_ancestor) @expected_ancestor = expected_ancestor end |
Instance Attribute Details
#expected_ancestor ⇒ Object (readonly)
Returns the value of attribute expected_ancestor.
20 21 22 |
# File 'lib/expected/matchers/inherit_from.rb', line 20 def expected_ancestor @expected_ancestor end |
#subject ⇒ Object
Returns the value of attribute subject.
20 21 22 |
# File 'lib/expected/matchers/inherit_from.rb', line 20 def subject @subject end |
Instance Method Details
#description ⇒ String
47 48 49 |
# File 'lib/expected/matchers/inherit_from.rb', line 47 def description "inherit_from: <#{expected_ancestor.inspect}>" end |
#failure_message ⇒ String
37 38 39 |
# File 'lib/expected/matchers/inherit_from.rb', line 37 def "Expected #{expectation}" end |
#failure_message_when_negated ⇒ String
42 43 44 |
# File 'lib/expected/matchers/inherit_from.rb', line 42 def "Did not expect #{expectation}" end |
#matches?(subject) ⇒ True, False
Run the test
31 32 33 34 |
# File 'lib/expected/matchers/inherit_from.rb', line 31 def matches?(subject) self.subject = subject self.subject.ancestors.include? expected_ancestor end |