class Caffeinate::RSpec::Matchers::UnsubscribeFromCaffeinateCampaign
Public Class Methods
new(expected_campaign, subscriber, **args)
click to toggle source
# 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
Public Instance Methods
description()
click to toggle source
# 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()
click to toggle source
# File lib/caffeinate/rspec/matchers/unsubscribe_from_caffeinate_campaign.rb, line 27 def failure_message "expected #{who} to unsubscribe from the \"Campaign##{@expected_campaign.slug}\" campaign but didn't" end
failure_message_when_negated()
click to toggle source
# File lib/caffeinate/rspec/matchers/unsubscribe_from_caffeinate_campaign.rb, line 42 def failure_message_when_negated "expected #{who} to not unsubscribe from the \"Campaign##{@expected_campaign.slug}\" campaign but did" end
matches?(block)
click to toggle source
Checks whether the block results in an unsubscribe from the expected campaign.
@param block [Block] The block of code to execute.
# 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?()
click to toggle source
# File lib/caffeinate/rspec/matchers/unsubscribe_from_caffeinate_campaign.rb, line 46 def supports_block_expectations? true end
Private Instance Methods
who()
click to toggle source
# File lib/caffeinate/rspec/matchers/unsubscribe_from_caffeinate_campaign.rb, line 52 def who str = "#{@subscriber.class.name}##{@subscriber.to_param}" user = @args[:user] if user str << "/#{user.class.name}##{user.to_param}" end if @args.except(:user).any? str << "/#{@args.except(:user).inspect}" end str end