Class: Expected::Matchers::HaveAttrAccessorMatcher
- Inherits:
-
Object
- Object
- Expected::Matchers::HaveAttrAccessorMatcher
- Defined in:
- lib/expected/matchers/have_attr_accessor.rb
Overview
Class used by #have_constant
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#has_attr_reader ⇒ Object
readonly
Returns the value of attribute has_attr_reader.
-
#has_attr_writer ⇒ Object
readonly
Returns the value of attribute has_attr_writer.
-
#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) ⇒ HaveAttrAccessorMatcher
constructor
A new instance of HaveAttrAccessorMatcher.
-
#matches?(subject) ⇒ True, False
Run the test.
Constructor Details
#initialize(attribute) ⇒ HaveAttrAccessorMatcher
Returns a new instance of HaveAttrAccessorMatcher.
27 28 29 30 31 32 33 34 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 27 def initialize(attribute) unless attribute.is_a?(String) || attribute.is_a?(Symbol) raise 'HaveAttrAccessorMatcher attribute must be a String or Symbol' end @attribute = attribute.to_sym @has_attr_reader = HaveAttrReaderMatcher.new(attribute) @has_attr_writer = HaveAttrWriterMatcher.new(attribute) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
24 25 26 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 24 def attribute @attribute end |
#has_attr_reader ⇒ Object (readonly)
Returns the value of attribute has_attr_reader.
24 25 26 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 24 def has_attr_reader @has_attr_reader end |
#has_attr_writer ⇒ Object (readonly)
Returns the value of attribute has_attr_writer.
24 25 26 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 24 def has_attr_writer @has_attr_writer end |
#subject ⇒ Object
Returns the value of attribute subject.
24 25 26 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 24 def subject @subject end |
Instance Method Details
#description ⇒ String
56 57 58 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 56 def description "have_attr_accessor: `#{attribute}`" end |
#failure_message ⇒ String
46 47 48 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 46 def "Expected #{expectation} (#{@failure})" end |
#failure_message_when_negated ⇒ String
51 52 53 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 51 def "Did not expect #{expectation}" end |
#matches?(subject) ⇒ True, False
Run the test
40 41 42 43 |
# File 'lib/expected/matchers/have_attr_accessor.rb', line 40 def matches?(subject) self.subject = subject matches_attr_reader? && matches_attr_writer? end |