Skip to content

Commit b6516ba

Browse files
authored
Merge pull request #1301 from rubocop/refactor-specs
Refactor specs to use offence substitution
2 parents 3142d2a + ea7d6e2 commit b6516ba

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

spec/rubocop/cop/rspec/factory_bot/syntax_methods_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
end
1818

1919
it "registers an offense for `FactoryBot.#{method}`" do
20-
expect_offense(<<~RUBY)
20+
expect_offense(<<~RUBY, method: method)
2121
describe Foo do
22-
let(:bar) { FactoryBot.#{method}(:bar) }
23-
^^^^^^^^^^^#{'^' * method.length} Use `#{method}` from `FactoryBot::Syntax::Methods`.
22+
let(:bar) { FactoryBot.%{method}(:bar) }
23+
^^^^^^^^^^^^{method} Use `%{method}` from `FactoryBot::Syntax::Methods`.
2424
end
2525
RUBY
2626

@@ -32,10 +32,10 @@
3232
end
3333

3434
it "registers an offense for `FactoryBot.#{method}` in a shared group" do
35-
expect_offense(<<~RUBY)
35+
expect_offense(<<~RUBY, method: method)
3636
shared_examples_for Foo do
37-
let(:bar) { FactoryBot.#{method}(:bar) }
38-
^^^^^^^^^^^#{'^' * method.length} Use `#{method}` from `FactoryBot::Syntax::Methods`.
37+
let(:bar) { FactoryBot.%{method}(:bar) }
38+
^^^^^^^^^^^^{method} Use `%{method}` from `FactoryBot::Syntax::Methods`.
3939
end
4040
RUBY
4141

@@ -47,10 +47,10 @@
4747
end
4848

4949
it "registers an offense for `::FactoryBot.#{method}`" do
50-
expect_offense(<<~RUBY)
50+
expect_offense(<<~RUBY, method: method)
5151
RSpec.describe Foo do
52-
let(:bar) { ::FactoryBot.#{method}(:bar) }
53-
^^^^^^^^^^^^^#{'^' * method.length} Use `#{method}` from `FactoryBot::Syntax::Methods`.
52+
let(:bar) { ::FactoryBot.%{method}(:bar) }
53+
^^^^^^^^^^^^^^{method} Use `%{method}` from `FactoryBot::Syntax::Methods`.
5454
end
5555
RUBY
5656

0 commit comments

Comments
 (0)