Skip to content

Commit

Permalink
Fix the mailer generator for rails 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Phippen committed Nov 22, 2015
1 parent ec555df commit cd82caf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/generators/rspec/mailer/templates/mailer_spec.rb
@@ -1,10 +1,10 @@
require "rails_helper"

<% module_namespacing do -%>
RSpec.describe <%= class_name %>, <%= type_metatag(:mailer) %> do
RSpec.describe <%= class_name %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>, <%= type_metatag(:mailer) %> do
<% for action in actions -%>
describe "<%= action %>" do
let(:mail) { <%= class_name %>.<%= action %> }
let(:mail) { <%= class_name %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>.<%= action %> }
it "renders the headers" do
expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
Expand Down
7 changes: 6 additions & 1 deletion spec/generators/rspec/mailer/mailer_generator_spec.rb
Expand Up @@ -13,7 +13,12 @@
end
it { is_expected.to exist }
it { is_expected.to contain(/require "rails_helper"/) }
it { is_expected.to contain(/^RSpec.describe Posts, #{type_metatag(:mailer)}/) }
if Rails.version.to_f >= 5.0
# Rails 5 automatically appends Mailer to the provided constant so we do too
it { is_expected.to contain(/^RSpec.describe PostsMailer, #{type_metatag(:mailer)}/) }
else
it { is_expected.to contain(/^RSpec.describe Posts, #{type_metatag(:mailer)}/) }
end
it { is_expected.to contain(/describe "index" do/) }
it { is_expected.to contain(/describe "show" do/) }
end
Expand Down

0 comments on commit cd82caf

Please sign in to comment.