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