We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For example, customize our model generator so that it generates specs with all the right it { is_expected.to respond_to(:attribute) } and such
it { is_expected.to respond_to(:attribute) }
The text was updated successfully, but these errors were encountered:
One nice thing would be if generated files got # frozen_string_literal: true at the top by default
# frozen_string_literal: true
Edit: Here's the code to do that:
# https://gist.github.com/ta1kt0me/6a7058d16621785d4f7038bde6cd3b98 module AddFrozenStringLiteralComment def add_frozen_string_literal_comment(dist) if File.exist?(dist) && File.extname(dist) == '.rb' File.open(dist, 'r') do |f| body = f.read File.open(dist, 'w') do |new_f| new_f.write("# frozen_string_literal: true\n\n" + body) end end end end end module GeneratorPrepend include AddFrozenStringLiteralComment def invoke! res = super add_frozen_string_literal_comment(existing_migration) res end end module TemplatePrepend include AddFrozenStringLiteralComment def template(source, *args, &block) res = super add_frozen_string_literal_comment(args.first) res end end Rails::Generators::Migration Rails::Generators::Actions::CreateMigration.send :prepend, GeneratorPrepend Rails::Generators::NamedBase.send :prepend, TemplatePrepend
It can go in config/initializers/generators/frozen_string_literal.rb
config/initializers/generators/frozen_string_literal.rb
Sorry, something went wrong.
No branches or pull requests
For example, customize our model generator so that it generates specs with all the right
it { is_expected.to respond_to(:attribute) }
and suchThe text was updated successfully, but these errors were encountered: