Class: Caffeinate::RSpec::Matchers::EndCaffeinateCampaignSubscription
- Inherits:
-
Object
- Object
- Caffeinate::RSpec::Matchers::EndCaffeinateCampaignSubscription
- Defined in:
- lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(expected_campaign, subscriber, **args) ⇒ EndCaffeinateCampaignSubscription
constructor
A new instance of EndCaffeinateCampaignSubscription.
-
#matches?(block) ⇒ Boolean
Checks whether the block results in the campaign subscription becoming ended.
- #supports_block_expectations? ⇒ Boolean
Constructor Details
#initialize(expected_campaign, subscriber, **args) ⇒ EndCaffeinateCampaignSubscription
Returns a new instance of EndCaffeinateCampaignSubscription.
17 18 19 20 21 |
# File 'lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb', line 17 def initialize(expected_campaign, subscriber, **args) @expected_campaign = expected_campaign @subscriber = subscriber @args = args end |
Instance Method Details
#description ⇒ Object
23 24 25 |
# File 'lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb', line 23 def description "end the CampaignSubscription of #{who} on the \"Campaign##{@expected_campaign.slug}\" campaign" end |
#failure_message ⇒ Object
27 28 29 |
# File 'lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb', line 27 def "expected the CampaignSubscription of #{who} on the \"Campaign##{@expected_campaign.slug}\" campaign to end but didn't" end |
#failure_message_when_negated ⇒ Object
42 43 44 |
# File 'lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb', line 42 def "expected the CampaignSubscription of #{who} on the \"Campaign##{@expected_campaign.slug}\" campaign to not end but did" end |
#matches?(block) ⇒ Boolean
Checks whether the block results in the campaign subscription becoming ended.
34 35 36 37 38 39 40 |
# File 'lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb', line 34 def matches?(block) sub = @expected_campaign.caffeinate_campaign_subscriptions.find_by(subscriber: @subscriber, **@args) return false unless sub && !sub.ended? block.call sub.reload.ended? end |
#supports_block_expectations? ⇒ Boolean
46 47 48 |
# File 'lib/caffeinate/rspec/matchers/end_caffeinate_campaign_subscription.rb', line 46 def supports_block_expectations? true end |