|
1 | 1 | require "rails_helper" |
2 | 2 | require Rails.root.join("lib/mailers/previews/devise_mailer_preview").to_s |
3 | 3 |
|
| 4 | +RSpec.shared_examples "invitation instructions" do |factory| |
| 5 | + let!(:record) { create(factory) } |
| 6 | + let(:message) { subject.send(:"invitation_instructions_as_#{factory}") } |
| 7 | + |
| 8 | + it { expect(message.to).to eq [record.email] } |
| 9 | +end |
| 10 | + |
4 | 11 | RSpec.describe DeviseMailerPreview do |
5 | 12 | let(:subject) { described_class.new } |
6 | 13 | let!(:user) { create(:user) } |
|
29 | 36 | end |
30 | 37 |
|
31 | 38 | describe "#invitation_instructions_as_all_casa_admin" do |
32 | | - let!(:all_casa_admin) { create(:all_casa_admin) } |
33 | | - let(:message) { subject.invitation_instructions_as_all_casa_admin } |
34 | | - |
35 | | - it { expect(message.to).to eq [all_casa_admin.email] } |
| 39 | + it_behaves_like "invitation instructions", :all_casa_admin |
36 | 40 | end |
37 | 41 |
|
38 | 42 | describe "#invitation_instructions_as_casa_admin" do |
39 | | - let!(:casa_admin) { create(:casa_admin) } |
40 | | - let(:message) { subject.invitation_instructions_as_casa_admin } |
41 | | - |
42 | | - it { expect(message.to).to eq [casa_admin.email] } |
| 43 | + it_behaves_like "invitation instructions", :casa_admin |
43 | 44 | end |
44 | 45 |
|
45 | 46 | describe "#invitation_instructions_as_supervisor" do |
46 | | - let!(:supervisor) { create(:supervisor) } |
47 | | - let(:message) { subject.invitation_instructions_as_supervisor } |
48 | | - |
49 | | - it { expect(message.to).to eq [supervisor.email] } |
| 47 | + it_behaves_like "invitation instructions", :supervisor |
50 | 48 | end |
51 | 49 |
|
52 | 50 | describe "#invitation_instructions_as_volunteer" do |
53 | | - let!(:volunteer) { create(:volunteer) } |
54 | | - let(:message) { subject.invitation_instructions_as_volunteer } |
55 | | - |
56 | | - it { expect(message.to).to eq [volunteer.email] } |
| 51 | + it_behaves_like "invitation instructions", :volunteer |
57 | 52 | end |
58 | 53 | end |
0 commit comments