Class: Caffeinate::RSpec::Matchers::BeSubscribedToCaffeinateCampaign

Inherits:
Object
  • Object
show all
Defined in:
lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_campaign) ⇒ BeSubscribedToCaffeinateCampaign

Returns a new instance of BeSubscribedToCaffeinateCampaign.



15
16
17
# File 'lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb', line 15

def initialize(expected_campaign)
  @expected_campaign = expected_campaign
end

Instance Method Details

#descriptionObject



19
20
21
# File 'lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb', line 19

def description
  "be subscribed to the \"Campaign##{@expected_campaign.slug}\" campaign"
end

#failure_messageObject



23
24
25
# File 'lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb', line 23

def failure_message
  "expected #{@hopeful_subscriber.inspect} to be subscribed to the \"Campaign##{@expected_campaign.slug}\" campaign but wasn't"
end

#failure_message_when_negatedObject



38
39
40
# File 'lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb', line 38

def failure_message_when_negated
  "expected #{@hopeful_subscriber.inspect} to not be subscribed to the \"Campaign##{@expected_campaign.slug}\" campaign but was"
end

#matches?(hopeful_subscriber) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb', line 32

def matches?(hopeful_subscriber)
  @hopeful_subscriber = hopeful_subscriber
  @args ||= {}
  @expected_campaign.caffeinate_campaign_subscriptions.exists?(subscriber: hopeful_subscriber, **@args)
end

#with(**args) ⇒ Object



27
28
29
30
# File 'lib/caffeinate/rspec/matchers/be_subscribed_to_caffeinate_campaign.rb', line 27

def with(**args)
  @args = args
  self
end