File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 22
33## Master (Unreleased)
44
5+ * Fix ` RSpec/FilePath ` detection when absolute path includes test subject. ([ @eitoball ] [ ] )
6+
57## 1.38.1 (2020-02-15)
68
79* Fix ` RSpec/RepeatedDescription ` to detect descriptions with interpolation and methods. ([ @lazycoder9 ] [ ] )
@@ -489,3 +491,4 @@ Compatibility release so users can upgrade RuboCop to 0.51.0. No new features.
489491[ @dduugg ] : https://github.com/dduugg
490492[ @lazycoder9 ] : https://github.com/lazycoder9
491493[ @elebow ] : https://github.com/elebow
494+ [ @eitoball ] : https://github.com/eitoball
Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ def ignore_methods?
103103 end
104104
105105 def filename_ends_with? ( glob )
106- File . fnmatch? ( "*#{ glob } " , processed_source . buffer . name )
106+ filename =
107+ RuboCop ::PathUtil . relative_path ( processed_source . buffer . name )
108+ File . fnmatch? ( "*#{ glob } " , filename )
107109 end
108110
109111 def relevant_rubocop_rspec_file? ( _file )
Original file line number Diff line number Diff line change 172172 RUBY
173173 end
174174
175+ it 'uses relative path' do
176+ allow ( RuboCop ::PathUtil )
177+ . to receive ( :relative_path ) . and_return ( 'spec/models/bar_spec.rb' )
178+ expect_offense ( <<-RUBY , '/home/foo/spec/models/bar_spec.rb' )
179+ describe Foo do; end
180+ ^^^^^^^^^^^^ Spec path should end with `foo*_spec.rb`.
181+ RUBY
182+ end
183+
175184 context 'when configured with CustomTransform' do
176185 let ( :cop_config ) { { 'CustomTransform' => { 'FooFoo' => 'foofoo' } } }
177186
You can’t perform that action at this time.
0 commit comments