Class: ElabsMatchers::Matchers::Persist::PersistMatcher
- Inherits:
-
Struct
- Object
- Struct
- ElabsMatchers::Matchers::Persist::PersistMatcher
- Defined in:
- lib/elabs_matchers/matchers/persist.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
- #matches?(record) ⇒ Boolean
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute
6 7 8 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 6 def attribute @attribute end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
7 8 9 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 7 def record @record end |
#value ⇒ Object
Returns the value of attribute value
6 7 8 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 6 def value @value end |
Instance Method Details
#description ⇒ Object
28 29 30 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 28 def description "persist #{attribute}" end |
#failure_message ⇒ Object Also known as: failure_message_for_should
18 19 20 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 18 def "Expected #{attribute} to be persisted and retain its value of #{value.inspect} but the value was #{@final_value.inspect}." end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
23 24 25 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 23 def "Expected #{attribute} not to be persisted and retain its value of #{value.inspect} but it did." end |
#matches?(record) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 9 def matches?(record) record.send(:"#{attribute}=", value) record.save! record = record.class.find(record.id) @final_value = record.send(attribute) @final_value == value end |