I would appreciate some help refactoring this shared_example.
describe "Sending Notifications" do
before(:all) do
create_basic_company_area_store # sets @company, @area, @store
@user = FactoryGirl.create(:user)
@company2 = FactoryGirl.create(:company)
end
shared_examples "sends all types" do
it 'sends an email' do
FactoryGirl.create(:email_notification, notification_type:
notif_type, user: user)
notification_email_with_expects(resource, expected_str)
end
end
describe 'Something Bad Happens' do
it_behaves_like "sends all types" do
let(:notif_type) { NotificationType.find_by_name("bad stuff") }
let(:user) { @user }
let(:resource) { @company2 }
let(:expected_str) { @company2.name }
end
end
describe 'Something Even Worse Happens' do
it_behaves_like "sends all types" do
let(:notif_type) { NotificationType.find_by_name("really bad stuff") }
let(:user) { @user }
let(:resource) { @company2 }
let(:expected_str) { @company2.name }
end
end
end
It works. But as I will need to test about 100 notification types, all
those 'let' statements will be a bit repetitious. How can I write this and
maybe knock it down to just 'it_behaves_like' single lines.
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rspec/-/iTLcahGMC-YJ.
For more options, visit https://groups.google.com/groups/opt_out.