Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAttrWriter
- Inherits:
-
Object
- Object
- ConvenientService::RSpec::PrimitiveMatchers::Classes::HaveAttrWriter
- Defined in:
- lib/convenient_service/rspec/primitive_matchers/classes/have_attr_writer.rb
Overview
TODO: Specs.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attr_name) ⇒ HaveAttrWriter
constructor
A new instance of HaveAttrWriter.
- #matches?(object) ⇒ Boolean
Constructor Details
#initialize(attr_name) ⇒ HaveAttrWriter
Returns a new instance of HaveAttrWriter.
11 12 13 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_writer.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_writer.rb', line 28 def description "have attr writer `#{attr_name}`" end |
#failure_message ⇒ Object
32 33 34 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_writer.rb', line 32 def "expected `#{object.class}` to have attr writer `#{attr_name}`" end |
#failure_message_when_negated ⇒ Object
36 37 38 |
# File 'lib/convenient_service/rspec/primitive_matchers/classes/have_attr_writer.rb', line 36 def "expected `#{object.class}` NOT to have attr writer `#{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_writer.rb', line 15 def matches?(object) @object = object ## # IMPORTANT: A copy is created in order to be thread safe. # copy = object.dup copy.public_send("#{attr_name}=", :custom_value) copy.instance_variable_get("@#{attr_name}") == :custom_value end |