spec/rubocop/cop/rspec/focus_spec.rb in rubocop-rspec-1.5.1 vs spec/rubocop/cop/rspec/focus_spec.rb in rubocop-rspec-1.5.2
- old
+ new
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
describe RuboCop::Cop::RSpec::Focus do
subject(:cop) { described_class.new }
[
:example_group, :describe, :context, :xdescribe, :xcontext,
@@ -10,11 +8,11 @@
].each do |block_type|
it "finds `#{block_type}` blocks with `focus: true`" do
inspect_source(
cop,
[
- "#{block_type} 'test', focus: true do",
+ "#{block_type} 'test', meta: true, focus: true do",
'end'
]
)
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.map(&:line).sort).to eq([1])
@@ -44,9 +42,19 @@
'end'
]
)
expect(subject.messages).to be_empty
end
+ end
+
+ it 'does not flag a method that is focused twice' do
+ inspect_source(cop, 'fit "foo", :focus do; end')
+ expect(cop.offenses.size).to be(1)
+ end
+
+ it 'ignores non-rspec code with :focus blocks' do
+ inspect_source(cop, 'some_method "foo", focus: true do; end')
+ expect(cop.offenses).to be_empty
end
[
:fdescribe, :fcontext,
:focus, :fexample, :fit, :fspecify,