Class: ModelTimeline::RSpec::Matchers::HaveTimelineEntry Private
- Inherits:
-
Object
- Object
- ModelTimeline::RSpec::Matchers::HaveTimelineEntry
- Defined in:
- lib/model_timeline/rspec/matchers.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
RSpec matcher to check if a model has timeline entries where an attribute changed to a specific value
Instance Method Summary collapse
-
#failure_message ⇒ String
private
Message displayed when the expectation fails.
-
#failure_message_when_negated ⇒ String
private
Message displayed when the negated expectation fails.
-
#initialize(attribute, value, association_name) ⇒ HaveTimelineEntry
constructor
private
Initialize the matcher.
-
#matches?(subject) ⇒ Boolean
private
Check if the subject matches the expectations.
Constructor Details
#initialize(attribute, value, association_name) ⇒ HaveTimelineEntry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the matcher
221 222 223 224 225 |
# File 'lib/model_timeline/rspec/matchers.rb', line 221 def initialize(attribute, value, association_name) @attribute = attribute.to_s @value = value @association_name = association_name end |
Instance Method Details
#failure_message ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Message displayed when the expectation fails
239 240 241 |
# File 'lib/model_timeline/rspec/matchers.rb', line 239 def "expected #{@subject} to have tracked '#{@attribute}' changing to '#{@value}', but no such change was found" end |
#failure_message_when_negated ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Message displayed when the negated expectation fails
246 247 248 |
# File 'lib/model_timeline/rspec/matchers.rb', line 246 def "expected #{@subject} not to have tracked '#{@attribute}' changing to '#{@value}', but such a change was found" end |
#matches?(subject) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the subject matches the expectations
231 232 233 234 |
# File 'lib/model_timeline/rspec/matchers.rb', line 231 def matches?(subject) @subject = subject @subject.public_send(@association_name).with_changed_value(@attribute, @value).exists? end |