generated from mattbrictson/gem
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use rubocop-rails >= 2.22.0 for better Rails 7.1 support (#9)
Before, rubocop-rails treated the Rails 7.1 `Rails.env.local?` as an unrecognized environment name, requiring custom configuration of `Rails/UnknownEnv` as a workaround. Now that rubocop-rails 2.22.0 is released, this workaround is no longer needed. This commit removes the workaround and ensures that `rubocop-rails` is added to the Gemfile with the `>= 2.22.0` version requirement.
- Loading branch information
1 parent
4a120f4
commit e0299a1
Showing
3 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require_relative "test_case" | ||
|
||
class Nextgen::Generators::RubocopTest < Nextgen::Generators::TestCase | ||
destination File.join(Dir.tmpdir, "test_#{SecureRandom.hex(8)}") | ||
setup :prepare_destination | ||
|
||
setup do | ||
%w[README.md Rakefile].each { FileUtils.touch Pathname.new(destination_root).join(_1) } | ||
Pathname.new(destination_root).join("Gemfile").write(<<~GEMFILE) | ||
source "https://rubygems.org" | ||
GEMFILE | ||
end | ||
|
||
test "adds rubocop gems in development group, with version spec for rubocop-rails" do | ||
apply_generator | ||
|
||
assert_file "Gemfile", /#{Regexp.quote(<<~GEMFILE)}/ | ||
group :development do | ||
gem "rubocop", require: false | ||
gem "rubocop-performance", require: false | ||
gem "rubocop-rails", ">= 2.22.0", require: false | ||
end | ||
GEMFILE | ||
end | ||
|
||
test "generates a .rubocop.yml file that requires additional plugins" do | ||
apply_generator | ||
|
||
assert_file ".rubocop.yml", /#{Regexp.quote(<<~YML)}/ | ||
require: | ||
- rubocop-performance | ||
- rubocop-rails | ||
YML | ||
end | ||
end |