Class: ModelTimeline::RSpec::Matchers::HaveTimelineAction Private
- Inherits:
-
Object
- Object
- ModelTimeline::RSpec::Matchers::HaveTimelineAction
- 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 with a specific action
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(action, association_name) ⇒ HaveTimelineAction
constructor
private
Initialize the matcher.
-
#matches?(subject) ⇒ Boolean
private
Check if the subject matches the expectations.
Constructor Details
#initialize(action, association_name) ⇒ HaveTimelineAction
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
148 149 150 151 |
# File 'lib/model_timeline/rspec/matchers.rb', line 148 def initialize(action, association_name) @action = action.to_s @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
165 166 167 |
# File 'lib/model_timeline/rspec/matchers.rb', line 165 def "expected #{@subject} to have recorded action '#{@action}', but none 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
172 173 174 |
# File 'lib/model_timeline/rspec/matchers.rb', line 172 def "expected #{@subject} not to have recorded action '#{@action}', but it 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
157 158 159 160 |
# File 'lib/model_timeline/rspec/matchers.rb', line 157 def matches?(subject) @subject = subject @subject.public_send(@association_name).where(action: @action).exists? end |