debian-mirror-gitlab/spec/support/email_helpers.rb
2016-09-13 17:45:13 +05:30

23 lines
559 B
Ruby

module EmailHelpers
def sent_to_user?(user)
ActionMailer::Base.deliveries.map(&:to).flatten.count(user.email) == 1
end
def reset_delivered_emails!
ActionMailer::Base.deliveries.clear
end
def should_only_email(*users)
users.each {|user| should_email(user) }
recipients = ActionMailer::Base.deliveries.flat_map(&:to)
expect(recipients.count).to eq(users.count)
end
def should_email(user)
expect(sent_to_user?(user)).to be_truthy
end
def should_not_email(user)
expect(sent_to_user?(user)).to be_falsey
end
end