OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/spec/mailers/shared_examples.rb

30 lines
818 B

shared_examples_for 'mail is sent' do
let(:letters_sent_count) { 1 }
let(:mail) { deliveries.first }
let(:html_body) { mail.body.parts.detect { |p| p.content_type.include? 'text/html' }.body.encoded }
it 'actually sends a mail' do
expect(deliveries.size).to eql(letters_sent_count)
end
it 'is sent to the recipient' do
expect(deliveries.first.to).to include(recipient.mail)
end
it 'is sent from the configured address' do
expect(deliveries.first.from).to match_array([Setting.mail_from])
end
end
shared_examples_for 'multiple mails are sent' do |set_letters_sent_count|
it_behaves_like 'mail is sent' do
let(:letters_sent_count) { set_letters_sent_count }
end
end
shared_examples_for 'mail is not sent' do
it 'sends no mail' do
expect(deliveries).to be_empty
end
end