Skip to content

removed rails 5.0 check for mailer spec generator #1729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2016

Conversation

hanumakanthvvn
Copy link
Contributor

Removed unnecessary code in lib/generators/rspec/mailer/templates/mailer_spec.rb

Now if we give rails g mailer CommentMailer
it generates the correct files/classes with file comment_mailer_spec.rb containing as
describe CommentMailer instead of CommentMailerMailer

Fixed: #1727

@JonRowe
Copy link
Member

JonRowe commented Oct 24, 2016

Hi, this needs to be here as the recommended way to add a mailer in Rails 5 is rails g mailer comment, which will add the Mailer part automatically. I'd support a change to see if it has a Mailer end part or not however.

@hanumakanthvvn
Copy link
Contributor Author

@JonRowe Oh ok got it will change accordingly, Thank you.

@hanumakanthvvn
Copy link
Contributor Author

@JonRowe Fixed. Please check it.

@@ -1,10 +1,10 @@
require "rails_helper"

<% module_namespacing do -%>
RSpec.describe <%= class_name %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>, <%= type_metatag(:mailer) %> do
RSpec.describe <%= class_name.gsub(/Mailer$/i, '') %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>, <%= type_metatag(:mailer) %> do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer it if we did this like this:

<%= Rails.version.to_f >= 5.0 ? class_name.gsub(/(Mailer)?$/i, 'Mailer') : class_name %>

As this will only run the modification on the edge case we know exists.

@JonRowe
Copy link
Member

JonRowe commented Oct 24, 2016

Thanks, I've suggested a slight improvement, see what you think :)

@hanumakanthvvn
Copy link
Contributor Author

@JonRowe Modified. Please review. Thanks

@JonRowe JonRowe merged commit 3caa42e into rspec:master Oct 25, 2016
@mltsy
Copy link

mltsy commented Oct 25, 2016

👍 😄

sebjacobs pushed a commit to futurelearn/rspec-rails that referenced this pull request Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants