Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAttrReader
- Inherits:
-
Object
- Object
- ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAttrReader
- Defined in:
- lib/convenient_service/rspec/primitive_matchers/classes/have_attr_reader.rb
Overview
TODO: Specs.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attr_name) ⇒ HaveAttrReader
constructor
A new instance of HaveAttrReader.
- #matches?(object) ⇒ Boolean
Constructor Details
#initialize(attr_name) ⇒ HaveAttrReader
Returns a new instance of HaveAttrReader.
11 12 13 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_reader.rb', line 11 def initialize(attr_name) @attr_name = attr_name end |
Instance Method Details
#description ⇒ Object
28 29 30 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_reader.rb', line 28 def description "have attr reader `#{attr_name}`" end |
#failure_message ⇒ Object
32 33 34 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_reader.rb', line 32 def "expected `#{object.class}` to have attr reader `#{attr_name}`" end |
#failure_message_when_negated ⇒ Object
36 37 38 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_reader.rb', line 36 def "expected `#{object.class}` NOT to have attr reader `#{attr_name}`" end |
#matches?(object) ⇒ Boolean
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_reader.rb', line 15 def matches?(object) @object = object ## # IMPORTANT: A copy is created in order to be thread safe. # copy = object.dup copy.instance_variable_set("@#{attr_name}", :custom_value) copy.public_send(attr_name) == :custom_value end |