Skip to content
This repository was archived by the owner on Sep 4, 2019. It is now read-only.

Commit 2336a42

Browse files
committed
Fix error when block method has no arguments.
1 parent 3876502 commit 2336a42

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## master (unreleased)
22

3+
* Fix error when block method has no arguments.
4+
35
## 0.0.2
46

57
* Support symbols passed as metadata, e.g:

lib/rubocop/cop/rspec/focused.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ def on_block(node)
4040
def focus_set_to_true?(metadata)
4141
return unless metadata
4242

43-
metadata.include?(s(:sym, :focus)) ||
43+
metadata.include?(s(:sym, :focus)) || (
44+
metadata.last &&
4445
metadata.last.children.any? do |pair|
4546
pair == s(:pair, s(:sym, :focus), s(:true))
4647
end
48+
)
4749
end
4850
end
4951
end

spec/lib/rubocop/cop/rspec/focused_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,13 @@
3232
expect(cop.offenses.map(&:line).sort).to eq([1])
3333
expect(cop.messages).to eq([described_class::MESSAGE])
3434
end
35+
36+
it 'does not raise error on block without arguments' do
37+
inspect_source(cop, ['it "does something" do',
38+
' expect(foo).to be_empty',
39+
'end'])
40+
expect(cop.offenses.size).to eq(0)
41+
expect(cop.offenses.map(&:line).sort).to be_empty
42+
expect(cop.messages).to be_empty
43+
end
3544
end

0 commit comments

Comments
 (0)