forked from rubocop/rubocop-rspec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into change_path
- Loading branch information
Showing
10 changed files
with
258 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'RuboCop::CLI run', :isolated_environment do # rubocop:disable RSpec/DescribeClass | ||
subject(:cli) { RuboCop::CLI.new } | ||
|
||
include_context 'when cli spec behavior' | ||
|
||
context 'when set option `AllowedIdentifiers` for ' \ | ||
'`RSpec/IndexedLet` and `Naming/VariableNumber`' do | ||
let(:exit_code) do | ||
cli.run(%w[--format simple --only RSpec/IndexedLet,Naming/VariableNumber]) | ||
end | ||
|
||
it 'does not offense for `RSpec/IndexedLet` ' \ | ||
'when set `AllowedIdentifiers` in `Naming/VariableNumber`' do | ||
create_file('.rubocop.yml', <<~YAML) | ||
RSpec/IndexedLet: | ||
Enabled: true | ||
AllowedPatterns: | ||
- foo | ||
Naming/VariableNumber: | ||
Enabled: true | ||
AllowedIdentifiers: | ||
- bar_1 | ||
- bar_2 | ||
YAML | ||
create_file('spec/example.rb', <<~RUBY) | ||
describe SomeService do | ||
let(:foo_1) { create(:foo) } | ||
let(:foo_2) { create(:foo) } | ||
let(:bar_1) { create(:bar) } | ||
let(:bar_2) { create(:bar) } | ||
let(:baz_1) { create(:baz) } | ||
let(:baz_2) { create(:baz) } | ||
end | ||
RUBY | ||
expect(exit_code).to eq(1) | ||
expect($stdout.string).to eq(<<~OUTPUT) | ||
== spec/example.rb == | ||
C: 2: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
C: 3: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
C: 6: 3: RSpec/IndexedLet: This let statement uses index in its name. Please give it a meaningful name. | ||
C: 6: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
C: 7: 3: RSpec/IndexedLet: This let statement uses index in its name. Please give it a meaningful name. | ||
C: 7: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
1 file inspected, 6 offenses detected | ||
OUTPUT | ||
end | ||
end | ||
|
||
context 'when set option `AllowedPatterns` for ' \ | ||
'`RSpec/IndexedLet` and `Naming/VariableNumber`' do | ||
let(:exit_code) do | ||
cli.run(%w[--format simple --only RSpec/IndexedLet,Naming/VariableNumber]) | ||
end | ||
|
||
it 'does not offense for `RSpec/IndexedLet` ' \ | ||
'when set `AllowedPatterns` in `Naming/VariableNumber`' do | ||
create_file('.rubocop.yml', <<~YAML) | ||
RSpec/IndexedLet: | ||
Enabled: true | ||
AllowedPatterns: | ||
- foo | ||
Naming/VariableNumber: | ||
Enabled: true | ||
AllowedPatterns: | ||
- bar | ||
YAML | ||
create_file('spec/example.rb', <<~RUBY) | ||
describe SomeService do | ||
let(:foo_1) { create(:foo) } | ||
let(:foo_2) { create(:foo) } | ||
let(:bar_1) { create(:bar) } | ||
let(:bar_2) { create(:bar) } | ||
let(:baz_1) { create(:baz) } | ||
let(:baz_2) { create(:baz) } | ||
end | ||
RUBY | ||
expect(exit_code).to eq(1) | ||
expect($stdout.string).to eq(<<~OUTPUT) | ||
== spec/example.rb == | ||
C: 2: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
C: 3: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
C: 6: 3: RSpec/IndexedLet: This let statement uses index in its name. Please give it a meaningful name. | ||
C: 6: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
C: 7: 3: RSpec/IndexedLet: This let statement uses index in its name. Please give it a meaningful name. | ||
C: 7: 7: Naming/VariableNumber: Use normalcase for symbol numbers. | ||
1 file inspected, 6 offenses detected | ||
OUTPUT | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters