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