File tree Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Expand file tree Collapse file tree 3 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 88* Update RuboCop dependency to 0.68.1 with support for children matching node pattern syntax. ([ @pirj ] [ ] )
99* Add ` RSpec/EmptyLineAfterExample ` cop to check that there is an empty line after example blocks. ([ @pirj ] [ ] )
1010* Fix ` Capybara/CurrentPathExpectation ` auto-corrector, to include option ` ignore_query: true ` . ([ @onumis ] [ ] )
11+ * Fix ` RSpec/Focus ` detecting mixed array/hash metadata. ([ @dgollahon ] [ ] )
12+ * Fix ` RSpec/Focus ` to also detect ` pending ` examples. ([ @dgollahon ] [ ] )
1113
1214## 1.35.0 (2019-08-02)
1315
Original file line number Diff line number Diff line change @@ -26,18 +26,16 @@ class Focus < Cop
2626 ExampleGroups ::GROUPS +
2727 ExampleGroups ::SKIPPED +
2828 Examples ::EXAMPLES +
29- Examples ::SKIPPED
29+ Examples ::SKIPPED +
30+ Examples ::PENDING
3031
3132 focused = ExampleGroups ::FOCUSED + Examples ::FOCUSED
3233
3334 FOCUSABLE_SELECTORS = focusable . node_pattern_union
3435
35- FOCUS_SYMBOL = s ( :sym , :focus )
36- FOCUS_TRUE = s ( :pair , FOCUS_SYMBOL , s ( :true ) )
37-
3836 def_node_matcher :metadata , <<-PATTERN
39- {(send #{ RSPEC } #{ FOCUSABLE_SELECTORS } ... (hash $ ...) )
40- (send #{ RSPEC } #{ FOCUSABLE_SELECTORS } $ ...)}
37+ {(send #{ RSPEC } #{ FOCUSABLE_SELECTORS } <$(sym :focus) ...> )
38+ (send #{ RSPEC } #{ FOCUSABLE_SELECTORS } ... (hash <$(pair (sym :focus) true) ...>) )}
4139 PATTERN
4240
4341 def_node_matcher :focused_block? , focused . send_pattern
@@ -53,10 +51,7 @@ def on_send(node)
5351 def focus_metadata ( node , &block )
5452 yield ( node ) if focused_block? ( node )
5553
56- metadata ( node ) do |matches |
57- matches . grep ( FOCUS_SYMBOL , &block )
58- matches . grep ( FOCUS_TRUE , &block )
59- end
54+ metadata ( node , &block )
6055 end
6156 end
6257 end
Original file line number Diff line number Diff line change 3838 ^^^^^^^^^^^ Focused spec found.
3939 xscenario 'test', meta: true, focus: true do; end
4040 ^^^^^^^^^^^ Focused spec found.
41+ pending 'test', meta: true, focus: true do; end
42+ ^^^^^^^^^^^ Focused spec found.
4143 RUBY
4244 end
4345
7577 ^^^^^^ Focused spec found.
7678 it 'test', :focus do; end
7779 ^^^^^^ Focused spec found.
80+ pending 'test', :focus do; end
81+ ^^^^^^ Focused spec found.
7882 RUBY
7983 end
8084 # rubocop:enable RSpec/ExampleLength
136140 ^^^^^^^^^^^^ Focused spec found.
137141 RUBY
138142 end
143+
144+ it 'flags rspec example blocks that include `:focus` preceding a hash' do
145+ expect_offense ( <<-RUBY )
146+ describe 'test', :focus, js: true do; end
147+ ^^^^^^ Focused spec found.
148+ RUBY
149+ end
139150end
You can’t perform that action at this time.
0 commit comments