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 788d153
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Bug fixes

* [#184](https://github.com/rubocop-hq/rubocop-rails/issues/184): Fix `Rake/Environment` to allow task with no block. ([@hanachin][])
* [#187](https://github.com/rubocop-hq/rubocop-rails/pull/187): Fix the issue that excluded files in rspec-rails did not work. ([@sinsoku][])

## 2.4.1 (2019-12-25)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rails/inject.rb
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
@@ -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 788d153

Please sign in to comment.