mirror of https://github.com/rails/rails
Merge pull request #51446 from koic/fix_error_when_rails_g_rubocop_with_pretend
Fix an error for `apply_rubocop_autocorrect_after_generate!` with `--pretend`
This commit is contained in:
commit
107fd51a22
|
@ -133,7 +133,7 @@ module Rails
|
|||
|
||||
def apply_rubocop_autocorrect_after_generate!
|
||||
after_generate do |files|
|
||||
parsable_files = files.filter { |file| file.end_with?(".rb") }
|
||||
parsable_files = files.filter { |file| File.exist?(file) && file.end_with?(".rb") }
|
||||
unless parsable_files.empty?
|
||||
system("bin/rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true)
|
||||
end
|
||||
|
|
|
@ -265,6 +265,16 @@ module ApplicationTests
|
|||
output = rails("generate", "model", "post", "title:string", "body:string")
|
||||
assert_match(/3 files inspected, no offenses detected/, output)
|
||||
end
|
||||
|
||||
test "generators with apply_rubocop_autocorrect_after_generate! and pretend" do
|
||||
with_config do |c|
|
||||
c.generators.apply_rubocop_autocorrect_after_generate!
|
||||
end
|
||||
|
||||
assert_nothing_raised do
|
||||
rails("generate", "model", "post", "title:string", "body:string", "--pretend")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue