Class: Expected::Matchers::HaveAttrReaderMatcher
- Inherits:
-
Object
- Object
- Expected::Matchers::HaveAttrReaderMatcher
- Defined in:
- lib/expected/matchers/have_attr_reader.rb
Overview
Class used by #have_constant
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #description ⇒ String
- #failure_message ⇒ String
- #failure_message_when_negated ⇒ String
-
#initialize(attribute) ⇒ HaveAttrReaderMatcher
constructor
A new instance of HaveAttrReaderMatcher.
-
#matches?(subject) ⇒ True, False
Run the test.
Constructor Details
#initialize(attribute) ⇒ HaveAttrReaderMatcher
Returns a new instance of HaveAttrReaderMatcher.
25 26 27 28 29 30 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 25 def initialize(attribute) unless attribute.is_a?(String) || attribute.is_a?(Symbol) raise 'HaveAttrReaderMatcher attribute must be a String or Symbol' end @attribute = attribute.to_sym end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
22 23 24 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 22 def attribute @attribute end |
#subject ⇒ Object
Returns the value of attribute subject.
22 23 24 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 22 def subject @subject end |
Instance Method Details
#description ⇒ String
53 54 55 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 53 def description "have_attr_reader: `#{attribute}`" end |
#failure_message ⇒ String
43 44 45 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 43 def "Expected #{expectation} (#{@failure})" end |
#failure_message_when_negated ⇒ String
48 49 50 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 48 def "Did not expect #{expectation}" end |
#matches?(subject) ⇒ True, False
Run the test
36 37 38 39 40 |
# File 'lib/expected/matchers/have_attr_reader.rb', line 36 def matches?(subject) self.subject = subject method? && returns_correct_value? end |