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)
-
- (Object) attribute
Returns the value of attribute attribute.
-
- (Object) record
readonly
Returns the value of attribute record.
-
- (Object) value
Returns the value of attribute value.
Instance Method Summary (collapse)
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
- - (Boolean) matches?(record)
Instance Attribute Details
- (Object) attribute
Returns the value of attribute attribute
6 7 8 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 6 def attribute @attribute end |
- (Object) record (readonly)
Returns the value of attribute record
7 8 9 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 7 def record @record end |
- (Object) value
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
- (Object) 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 |
- (Object) failure_message_for_should_not
22 23 24 |
# File 'lib/elabs_matchers/matchers/persist.rb', line 22 def "Expected #{attribute} not to be persisted and retain its value of #{value.inspect} but it did." end |
- (Boolean) matches?(record)
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 |