Skip to content

Commit

Permalink
Fix the issue that excluded files in rspec-rails did not work
Browse files Browse the repository at this point in the history
`bin/*` and `db/schema.rb` were not excluded.
Exclude files should be absolute paths internally, so it fixes to call the `make_excludes_absolute` method.

Ref: rubocop/rubocop@cb63798
  • Loading branch information
sinsoku committed Jan 11, 2020
1 parent 92c3c6f commit adb09a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubocop/rails/inject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Inject
def self.defaults!
path = CONFIG_DEFAULT.to_s
hash = ConfigLoader.send(:load_yaml_configuration, path)
config = Config.new(hash, path)
config = Config.new(hash, path).tap(&:make_excludes_absolute)
puts "configuration from #{path}" if ConfigLoader.debug?
config = ConfigLoader.merge_with_default(config, path, unset_nil: false)
ConfigLoader.instance_variable_set(:@default_configuration, config)
Expand Down
16 changes: 16 additions & 0 deletions spec/rubocop/rails/inject_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Rails::Inject do
describe '#defaults!' do
before { allow(Dir).to receive(:pwd).and_return('/home/foo/project') }

it 'makes excludes absolute' do
configuration = described_class.defaults!
expect(configuration['AllCops']['Exclude'])
.to eq [
'/home/foo/project/bin/*',
'/home/foo/project/db/schema.rb'
]
end
end
end

0 comments on commit adb09a7

Please sign in to comment.