rubocop-rspec 1.15.1 → 1.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/Gemfile +0 -1
  4. data/config/default.yml +105 -0
  5. data/lib/rubocop-rspec.rb +27 -0
  6. data/lib/rubocop/cop/rspec/align_left_let_brace.rb +51 -0
  7. data/lib/rubocop/cop/rspec/align_right_let_brace.rb +51 -0
  8. data/lib/rubocop/cop/rspec/any_instance.rb +1 -1
  9. data/lib/rubocop/cop/rspec/cop.rb +4 -2
  10. data/lib/rubocop/cop/rspec/expect_in_hook.rb +61 -0
  11. data/lib/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically.rb +84 -0
  12. data/lib/rubocop/cop/rspec/hook_argument.rb +11 -5
  13. data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +42 -0
  14. data/lib/rubocop/cop/rspec/let_before_examples.rb +66 -0
  15. data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -5
  16. data/lib/rubocop/cop/rspec/multiple_subjects.rb +80 -0
  17. data/lib/rubocop/cop/rspec/named_subject.rb +5 -6
  18. data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
  19. data/lib/rubocop/cop/rspec/predicate_matcher.rb +337 -0
  20. data/lib/rubocop/cop/rspec/return_from_stub.rb +83 -0
  21. data/lib/rubocop/cop/rspec/void_expect.rb +52 -0
  22. data/lib/rubocop/rspec/align_let_brace.rb +64 -0
  23. data/lib/rubocop/rspec/config_formatter.rb +7 -4
  24. data/lib/rubocop/rspec/description_extractor.rb +2 -2
  25. data/lib/rubocop/rspec/example_group.rb +25 -2
  26. data/lib/rubocop/rspec/factory_girl.rb +7 -0
  27. data/lib/rubocop/rspec/language.rb +6 -1
  28. data/lib/rubocop/rspec/version.rb +1 -1
  29. data/rubocop-rspec.gemspec +1 -4
  30. data/spec/project/default_config_spec.rb +8 -4
  31. data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +62 -0
  32. data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +62 -0
  33. data/spec/rubocop/cop/rspec/any_instance_spec.rb +3 -3
  34. data/spec/rubocop/cop/rspec/around_block_spec.rb +11 -11
  35. data/spec/rubocop/cop/rspec/be_eql_spec.rb +7 -7
  36. data/spec/rubocop/cop/rspec/before_after_all_spec.rb +4 -4
  37. data/spec/rubocop/cop/rspec/cop_spec.rb +7 -7
  38. data/spec/rubocop/cop/rspec/describe_class_spec.rb +18 -18
  39. data/spec/rubocop/cop/rspec/describe_method_spec.rb +4 -4
  40. data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +6 -6
  41. data/spec/rubocop/cop/rspec/described_class_spec.rb +18 -18
  42. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +5 -5
  43. data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +9 -9
  44. data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +5 -5
  45. data/spec/rubocop/cop/rspec/example_length_spec.rb +6 -6
  46. data/spec/rubocop/cop/rspec/example_wording_spec.rb +10 -10
  47. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +10 -10
  48. data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +79 -0
  49. data/spec/rubocop/cop/rspec/expect_output_spec.rb +7 -7
  50. data/spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb +87 -0
  51. data/spec/rubocop/cop/rspec/file_path_spec.rb +29 -29
  52. data/spec/rubocop/cop/rspec/focus_spec.rb +6 -6
  53. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +35 -23
  54. data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +10 -10
  55. data/spec/rubocop/cop/rspec/instance_spy_spec.rb +4 -4
  56. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +7 -7
  57. data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +37 -0
  58. data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +4 -4
  59. data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +8 -8
  60. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +5 -5
  61. data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +83 -0
  62. data/spec/rubocop/cop/rspec/let_setup_spec.rb +4 -4
  63. data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -2
  64. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +4 -4
  65. data/spec/rubocop/cop/rspec/message_spies_spec.rb +18 -18
  66. data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +3 -3
  67. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +45 -9
  68. data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +96 -0
  69. data/spec/rubocop/cop/rspec/named_subject_spec.rb +4 -4
  70. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +3 -3
  71. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +4 -4
  72. data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +4 -4
  73. data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +335 -0
  74. data/spec/rubocop/cop/rspec/repeated_description_spec.rb +5 -5
  75. data/spec/rubocop/cop/rspec/repeated_example_spec.rb +5 -5
  76. data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +85 -0
  77. data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -2
  78. data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +8 -8
  79. data/spec/rubocop/cop/rspec/shared_context_spec.rb +10 -10
  80. data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +10 -10
  81. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +9 -9
  82. data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +7 -7
  83. data/spec/rubocop/cop/rspec/void_expect_spec.rb +47 -0
  84. data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
  85. data/spec/spec_helper.rb +1 -1
  86. data/spec/support/expect_offense.rb +17 -0
  87. metadata +39 -51
  88. data/spec/expect_violation/expectation_spec.rb +0 -85
  89. data/spec/support/expect_violation.rb +0 -170
@@ -4,7 +4,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
4
4
  subject(:cop) { described_class.new(config) }
5
5
 
6
6
  it 'flags numeric literal values within expect(...)' do
7
- expect_violation(<<-RUBY)
7
+ expect_offense(<<-RUBY)
8
8
  describe Foo do
9
9
  it 'uses expect incorrectly' do
10
10
  expect(123).to eq(bar)
@@ -21,7 +21,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
21
21
  end
22
22
 
23
23
  it 'flags boolean literal values within expect(...)' do
24
- expect_violation(<<-RUBY)
24
+ expect_offense(<<-RUBY)
25
25
  describe Foo do
26
26
  it 'uses expect incorrectly' do
27
27
  expect(true).to eq(bar)
@@ -34,7 +34,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
34
34
  end
35
35
 
36
36
  it 'flags string and symbol literal values within expect(...)' do
37
- expect_violation(<<-RUBY)
37
+ expect_offense(<<-RUBY)
38
38
  describe Foo do
39
39
  it 'uses expect incorrectly' do
40
40
  expect("foo").to eq(bar)
@@ -47,7 +47,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
47
47
  end
48
48
 
49
49
  it 'flags literal nil value within expect(...)' do
50
- expect_violation(<<-RUBY)
50
+ expect_offense(<<-RUBY)
51
51
  describe Foo do
52
52
  it 'uses expect incorrectly' do
53
53
  expect(nil).to eq(bar)
@@ -58,7 +58,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
58
58
  end
59
59
 
60
60
  it 'does not flag dynamic values within expect(...)' do
61
- expect_no_violations(<<-'RUBY')
61
+ expect_no_offenses(<<-'RUBY')
62
62
  describe Foo do
63
63
  it 'uses expect correctly' do
64
64
  expect(foo).to eq(bar)
@@ -70,7 +70,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
70
70
  end
71
71
 
72
72
  it 'flags arrays containing only literal values within expect(...)' do
73
- expect_violation(<<-RUBY)
73
+ expect_offense(<<-RUBY)
74
74
  describe Foo do
75
75
  it 'uses expect incorrectly' do
76
76
  expect([123]).to eq(bar)
@@ -83,7 +83,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
83
83
  end
84
84
 
85
85
  it 'flags hashes containing only literal values within expect(...)' do
86
- expect_violation(<<-RUBY)
86
+ expect_offense(<<-RUBY)
87
87
  describe Foo do
88
88
  it 'uses expect incorrectly' do
89
89
  expect(foo: 1, bar: 2).to eq(bar)
@@ -96,7 +96,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
96
96
  end
97
97
 
98
98
  it 'flags ranges containing only literal values within expect(...)' do
99
- expect_violation(<<-RUBY)
99
+ expect_offense(<<-RUBY)
100
100
  describe Foo do
101
101
  it 'uses expect incorrectly' do
102
102
  expect(1..2).to eq(bar)
@@ -109,7 +109,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
109
109
  end
110
110
 
111
111
  it 'flags regexps containing only literal values within expect(...)' do
112
- expect_violation(<<-RUBY)
112
+ expect_offense(<<-RUBY)
113
113
  describe Foo do
114
114
  it 'uses expect incorrectly' do
115
115
  expect(/foo|bar/).to eq(bar)
@@ -120,7 +120,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectActual, :config do
120
120
  end
121
121
 
122
122
  it 'does not flag complex values with dynamic parts within expect(...)' do
123
- expect_no_violations(<<-'RUBY')
123
+ expect_no_offenses(<<-'RUBY')
124
124
  describe Foo do
125
125
  it 'uses expect incorrectly' do
126
126
  expect.to eq(bar)
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe RuboCop::Cop::RSpec::ExpectInHook do
4
+ subject(:cop) { described_class.new }
5
+
6
+ it 'adds an offense for `expect` in `before` hook' do
7
+ expect_offense(<<-RUBY)
8
+ before do
9
+ expect(something).to eq('foo')
10
+ ^^^^^^ Do not use `expect` in `before` hook
11
+ is_expected.to eq('foo')
12
+ ^^^^^^^^^^^ Do not use `is_expected` in `before` hook
13
+ expect_any_instance_of(Something).to receive(:foo)
14
+ ^^^^^^^^^^^^^^^^^^^^^^ Do not use `expect_any_instance_of` in `before` hook
15
+ end
16
+ RUBY
17
+ end
18
+
19
+ it 'adds an offense for `expect` in `after` hook' do
20
+ expect_offense(<<-RUBY)
21
+ after do
22
+ expect(something).to eq('foo')
23
+ ^^^^^^ Do not use `expect` in `after` hook
24
+ is_expected.to eq('foo')
25
+ ^^^^^^^^^^^ Do not use `is_expected` in `after` hook
26
+ expect_any_instance_of(Something).to receive(:foo)
27
+ ^^^^^^^^^^^^^^^^^^^^^^ Do not use `expect_any_instance_of` in `after` hook
28
+ end
29
+ RUBY
30
+ end
31
+
32
+ it 'adds an offense for `expect` in `around` hook' do
33
+ expect_offense(<<-RUBY)
34
+ around do
35
+ expect(something).to eq('foo')
36
+ ^^^^^^ Do not use `expect` in `around` hook
37
+ is_expected(something).to eq('foo')
38
+ ^^^^^^^^^^^ Do not use `is_expected` in `around` hook
39
+ expect_any_instance_of(Something).to receive(:foo)
40
+ ^^^^^^^^^^^^^^^^^^^^^^ Do not use `expect_any_instance_of` in `around` hook
41
+ end
42
+ RUBY
43
+ end
44
+
45
+ it 'adds an offense for `expect` with block in `before` hook' do
46
+ expect_offense(<<-RUBY)
47
+ before do
48
+ expect { something }.to eq('foo')
49
+ ^^^^^^ Do not use `expect` in `before` hook
50
+ end
51
+ RUBY
52
+ end
53
+
54
+ it 'accepts an empty `before` hook' do
55
+ expect_no_offenses(<<-RUBY)
56
+ before do
57
+ end
58
+ RUBY
59
+ end
60
+
61
+ it 'accepts `allow` in `before` hook' do
62
+ expect_no_offenses(<<-RUBY)
63
+ before do
64
+ allow(something).to receive(:foo)
65
+ allow_any_instance_of(something).to receive(:foo)
66
+ end
67
+ RUBY
68
+ end
69
+
70
+ it 'accepts `expect` in `it`' do
71
+ expect_no_offenses(<<-RUBY)
72
+ it do
73
+ expect(something).to eq('foo')
74
+ is_expected.to eq('foo')
75
+ expect_any_instance_of(something).to receive(:foo)
76
+ end
77
+ RUBY
78
+ end
79
+ end
@@ -6,7 +6,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
6
6
  subject(:cop) { described_class.new }
7
7
 
8
8
  it 'registers an offense for overwriting $stdout within an example' do
9
- expect_violation(<<-RUBY)
9
+ expect_offense(<<-RUBY)
10
10
  specify do
11
11
  $stdout = StringIO.new
12
12
  ^^^^^^^ Use `expect { ... }.to output(...).to_stdout` instead of mutating $stdout.
@@ -16,7 +16,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
16
16
 
17
17
  it 'registers an offense for overwriting $stderr ' \
18
18
  'within an example scoped hook' do
19
- expect_violation(<<-RUBY)
19
+ expect_offense(<<-RUBY)
20
20
  before(:each) do
21
21
  $stderr = StringIO.new
22
22
  ^^^^^^^ Use `expect { ... }.to output(...).to_stderr` instead of mutating $stderr.
@@ -25,7 +25,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
25
25
  end
26
26
 
27
27
  it 'does not register an offense for interacting with $stdout' do
28
- expect_no_violations(<<-RUBY)
28
+ expect_no_offenses(<<-RUBY)
29
29
  specify do
30
30
  $stdout.puts("hi")
31
31
  end
@@ -33,7 +33,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
33
33
  end
34
34
 
35
35
  it 'does not flag assignments to other global variables' do
36
- expect_no_violations(<<-RUBY)
36
+ expect_no_offenses(<<-RUBY)
37
37
  specify do
38
38
  $blah = StringIO.new
39
39
  end
@@ -41,7 +41,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
41
41
  end
42
42
 
43
43
  it 'does not flag assignments to $stdout outside of example scope' do
44
- expect_no_violations(<<-RUBY)
44
+ expect_no_offenses(<<-RUBY)
45
45
  before(:suite) do
46
46
  $stderr = StringIO.new
47
47
  end
@@ -49,7 +49,7 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
49
49
  end
50
50
 
51
51
  it 'does not flag assignments to $stdout in example_group scope' do
52
- expect_no_violations(<<-RUBY)
52
+ expect_no_offenses(<<-RUBY)
53
53
  describe Foo do
54
54
  $stderr = StringIO.new
55
55
  end
@@ -57,6 +57,6 @@ RSpec.describe RuboCop::Cop::RSpec::ExpectOutput do
57
57
  end
58
58
 
59
59
  it 'does not flag assigns to $stdout when in the root scope' do
60
- expect_no_violations('$stderr = StringIO.new')
60
+ expect_no_offenses('$stderr = StringIO.new')
61
61
  end
62
62
  end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/LineLength
4
+ RSpec.describe RuboCop::Cop::RSpec::FactoryGirl::DynamicAttributeDefinedStatically do
5
+ subject(:cop) { described_class.new(config) }
6
+
7
+ let(:config) { RuboCop::Config.new }
8
+
9
+ it 'registers an offense for offending code' do
10
+ expect_offense(<<-RUBY)
11
+ FactoryGirl.define do
12
+ factory :post do
13
+ published_at 1.day.from_now
14
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use a block to set a dynamic value to an attribute.
15
+ status [:draft, :published].sample
16
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use a block to set a dynamic value to an attribute.
17
+ created_at 1.day.ago
18
+ ^^^^^^^^^^^^^^^^^^^^ Use a block to set a dynamic value to an attribute.
19
+ end
20
+ end
21
+ RUBY
22
+ end
23
+
24
+ it 'registers an offense in a trait' do
25
+ expect_offense(<<-RUBY)
26
+ FactoryGirl.define do
27
+ factory :post do
28
+ title "Something"
29
+ trait :published do
30
+ published_at 1.day.from_now
31
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use a block to set a dynamic value to an attribute.
32
+ end
33
+ end
34
+ end
35
+ RUBY
36
+ end
37
+
38
+ it 'accepts' do
39
+ expect_no_offenses(<<-RUBY)
40
+ FactoryGirl.define do
41
+ factory :post do
42
+ trait :published do
43
+ published_at { 1.day.from_now }
44
+ end
45
+ created_at { 1.day.ago }
46
+ status :draft
47
+ comments_count 0
48
+ title "Static"
49
+ description { FFaker::Lorem.paragraph(10) }
50
+ tag Tag::MAGIC
51
+ end
52
+ end
53
+ RUBY
54
+ end
55
+
56
+ it 'does not add offense if out of factory girl block' do
57
+ expect_no_offenses(<<-RUBY)
58
+ status [:draft, :published].sample
59
+ published_at 1.day.from_now
60
+ created_at 1.day.ago
61
+ RUBY
62
+ end
63
+
64
+ bad = <<-RUBY
65
+ FactoryGirl.define do
66
+ factory :post do
67
+ status([:draft, :published].sample)
68
+ published_at 1.day.from_now
69
+ created_at(1.day.ago)
70
+ updated_at Time.current
71
+ end
72
+ end
73
+ RUBY
74
+
75
+ corrected = <<-RUBY
76
+ FactoryGirl.define do
77
+ factory :post do
78
+ status { [:draft, :published].sample }
79
+ published_at { 1.day.from_now }
80
+ created_at { 1.day.ago }
81
+ updated_at { Time.current }
82
+ end
83
+ end
84
+ RUBY
85
+
86
+ include_examples 'autocorrect', bad, corrected
87
+ end
@@ -2,170 +2,170 @@ RSpec.describe RuboCop::Cop::RSpec::FilePath, :config do
2
2
  subject(:cop) { described_class.new(config) }
3
3
 
4
4
  it 'registers an offense for a bad path' do
5
- expect_violation(<<-RUBY, filename: 'wrong_path_foo_spec.rb')
5
+ expect_offense(<<-RUBY, 'wrong_path_foo_spec.rb')
6
6
  describe MyClass, 'foo' do; end
7
7
  ^^^^^^^^^^^^^^^^^^^^^^^ Spec path should end with `my_class*foo*_spec.rb`.
8
8
  RUBY
9
9
  end
10
10
 
11
11
  it 'registers an offense for a wrong class but a correct method' do
12
- expect_violation(<<-RUBY, filename: 'wrong_class_foo_spec.rb')
12
+ expect_offense(<<-RUBY, 'wrong_class_foo_spec.rb')
13
13
  describe MyClass, '#foo' do; end
14
14
  ^^^^^^^^^^^^^^^^^^^^^^^^ Spec path should end with `my_class*foo*_spec.rb`.
15
15
  RUBY
16
16
  end
17
17
 
18
18
  it 'registers an offense for a repeated .rb' do
19
- expect_violation(<<-RUBY, filename: 'my_class/foo_spec.rb.rb')
19
+ expect_offense(<<-RUBY, 'my_class/foo_spec.rb.rb')
20
20
  describe MyClass, '#foo' do; end
21
21
  ^^^^^^^^^^^^^^^^^^^^^^^^ Spec path should end with `my_class*foo*_spec.rb`.
22
22
  RUBY
23
23
  end
24
24
 
25
25
  it 'registers an offense for a file missing a .rb' do
26
- expect_violation(<<-RUBY, filename: 'my_class/foo_specorb')
26
+ expect_offense(<<-RUBY, 'my_class/foo_specorb')
27
27
  describe MyClass, '#foo' do; end
28
28
  ^^^^^^^^^^^^^^^^^^^^^^^^ Spec path should end with `my_class*foo*_spec.rb`.
29
29
  RUBY
30
30
  end
31
31
 
32
32
  it 'registers an offense for a wrong class and highlights metadata' do
33
- expect_violation(<<-RUBY, filename: 'wrong_class_foo_spec.rb')
33
+ expect_offense(<<-RUBY, 'wrong_class_foo_spec.rb')
34
34
  describe MyClass, '#foo', blah: :blah do; end
35
35
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Spec path should end with `my_class*foo*_spec.rb`.
36
36
  RUBY
37
37
  end
38
38
 
39
39
  it 'registers an offense for a wrong class name' do
40
- expect_violation(<<-RUBY, filename: 'wrong_class_spec.rb')
40
+ expect_offense(<<-RUBY, 'wrong_class_spec.rb')
41
41
  describe MyClass do; end
42
42
  ^^^^^^^^^^^^^^^^ Spec path should end with `my_class*_spec.rb`.
43
43
  RUBY
44
44
  end
45
45
 
46
46
  it 'registers an offense for a wrong class name with a symbol argument' do
47
- expect_violation(<<-RUBY, filename: 'wrong_class_spec.rb')
47
+ expect_offense(<<-RUBY, 'wrong_class_spec.rb')
48
48
  describe MyClass, :foo do; end
49
49
  ^^^^^^^^^^^^^^^^^^^^^^ Spec path should end with `my_class*_spec.rb`.
50
50
  RUBY
51
51
  end
52
52
 
53
53
  it 'registers an offense for a file missing _spec' do
54
- expect_violation(<<-RUBY, filename: 'user.rb')
54
+ expect_offense(<<-RUBY, 'user.rb')
55
55
  describe User do; end
56
56
  ^^^^^^^^^^^^^ Spec path should end with `user*_spec.rb`.
57
57
  RUBY
58
58
  end
59
59
 
60
60
  it 'skips specs that do not describe a class / method' do
61
- expect_no_violations(<<-RUBY, filename: 'some/class/spec.rb')
61
+ expect_no_offenses(<<-RUBY, 'some/class/spec.rb')
62
62
  describe 'Test something' do; end
63
63
  RUBY
64
64
  end
65
65
 
66
66
  it 'skips specs that do have multiple top level describes' do
67
- expect_no_violations(<<-RUBY, filename: 'some/class/spec.rb')
67
+ expect_no_offenses(<<-RUBY, 'some/class/spec.rb')
68
68
  describe MyClass, 'do_this' do; end
69
69
  describe MyClass, 'do_that' do; end
70
70
  RUBY
71
71
  end
72
72
 
73
73
  it 'checks class specs' do
74
- expect_no_violations(<<-RUBY, filename: 'some/class_spec.rb')
74
+ expect_no_offenses(<<-RUBY, 'some/class_spec.rb')
75
75
  describe Some::Class do; end
76
76
  RUBY
77
77
  end
78
78
 
79
79
  it 'allows different parent directories' do
80
- expect_no_violations(<<-RUBY, filename: 'parent_dir/some/class_spec.rb')
80
+ expect_no_offenses(<<-RUBY, 'parent_dir/some/class_spec.rb')
81
81
  describe Some::Class do; end
82
82
  RUBY
83
83
  end
84
84
 
85
85
  it 'handles CamelCaps class names' do
86
- expect_no_violations(<<-RUBY, filename: 'my_class_spec.rb')
86
+ expect_no_offenses(<<-RUBY, 'my_class_spec.rb')
87
87
  describe MyClass do; end
88
88
  RUBY
89
89
  end
90
90
 
91
91
  it 'handles ACRONYMClassNames' do
92
- expect_no_violations(<<-RUBY, filename: 'abc_one/two_spec.rb')
92
+ expect_no_offenses(<<-RUBY, 'abc_one/two_spec.rb')
93
93
  describe ABCOne::Two do; end
94
94
  RUBY
95
95
  end
96
96
 
97
97
  it 'handles ALLCAPS class names' do
98
- expect_no_violations(<<-RUBY, filename: 'allcaps_spec.rb')
98
+ expect_no_offenses(<<-RUBY, 'allcaps_spec.rb')
99
99
  describe ALLCAPS do; end
100
100
  RUBY
101
101
  end
102
102
 
103
103
  it 'handles alphanumeric class names' do
104
- expect_no_violations(<<-RUBY, filename: 'ipv4_and_ipv6_spec.rb')
104
+ expect_no_offenses(<<-RUBY, 'ipv4_and_ipv6_spec.rb')
105
105
  describe IPV4AndIPV6 do; end
106
106
  RUBY
107
107
  end
108
108
 
109
109
  it 'checks instance methods' do
110
- expect_no_violations(<<-RUBY, filename: 'some/class/inst_spec.rb')
110
+ expect_no_offenses(<<-RUBY, 'some/class/inst_spec.rb')
111
111
  describe Some::Class, '#inst' do; end
112
112
  RUBY
113
113
  end
114
114
 
115
115
  it 'checks class methods' do
116
- expect_no_violations(<<-RUBY, filename: 'some/class/inst_spec.rb')
116
+ expect_no_offenses(<<-RUBY, 'some/class/inst_spec.rb')
117
117
  describe Some::Class, '.inst' do; end
118
118
  RUBY
119
119
  end
120
120
 
121
121
  it 'allows flat hierarchies for instance methods' do
122
- expect_no_violations(<<-RUBY, filename: 'some/class_inst_spec.rb')
122
+ expect_no_offenses(<<-RUBY, 'some/class_inst_spec.rb')
123
123
  describe Some::Class, '#inst' do; end
124
124
  RUBY
125
125
  end
126
126
 
127
127
  it 'allows flat hierarchies for class methods' do
128
- expect_no_violations(<<-RUBY, filename: 'some/class_inst_spec.rb')
128
+ expect_no_offenses(<<-RUBY, 'some/class_inst_spec.rb')
129
129
  describe Some::Class, '.inst' do; end
130
130
  RUBY
131
131
  end
132
132
 
133
133
  it 'allows subdirs for instance methods' do
134
134
  filename = 'some/class/instance_methods/inst_spec.rb'
135
- expect_no_violations(<<-RUBY, filename: filename)
135
+ expect_no_offenses(<<-RUBY, filename)
136
136
  describe Some::Class, '#inst' do; end
137
137
  RUBY
138
138
  end
139
139
 
140
140
  it 'allows subdirs for class methods' do
141
141
  filename = 'some/class/class_methods/inst_spec.rb'
142
- expect_no_violations(<<-RUBY, filename: filename)
142
+ expect_no_offenses(<<-RUBY, filename)
143
143
  describe Some::Class, '.inst' do; end
144
144
  RUBY
145
145
  end
146
146
 
147
147
  it 'ignores non-alphanumeric characters' do
148
- expect_no_violations(<<-RUBY, filename: 'some/class/pred_spec.rb')
148
+ expect_no_offenses(<<-RUBY, 'some/class/pred_spec.rb')
149
149
  describe Some::Class, '#pred?' do; end
150
150
  RUBY
151
151
  end
152
152
 
153
153
  it 'allows bang method' do
154
- expect_no_violations(<<-RUBY, filename: 'some/class/bang_spec.rb')
154
+ expect_no_offenses(<<-RUBY, 'some/class/bang_spec.rb')
155
155
  describe Some::Class, '#bang!' do; end
156
156
  RUBY
157
157
  end
158
158
 
159
159
  it 'allows flexibility with predicates' do
160
160
  filename = 'some/class/thing_predicate_spec.rb'
161
- expect_no_violations(<<-RUBY, filename: filename)
161
+ expect_no_offenses(<<-RUBY, filename)
162
162
  describe Some::Class, '#thing?' do; end
163
163
  RUBY
164
164
  end
165
165
 
166
166
  it 'allows flexibility with operators' do
167
167
  filename = 'my_little_class/spaceship_operator_spec.rb'
168
- expect_no_violations(<<-RUBY, filename: filename)
168
+ expect_no_offenses(<<-RUBY, filename)
169
169
  describe MyLittleClass, '#<=>' do; end
170
170
  RUBY
171
171
  end
@@ -174,13 +174,13 @@ RSpec.describe RuboCop::Cop::RSpec::FilePath, :config do
174
174
  let(:cop_config) { { 'CustomTransform' => { 'FooFoo' => 'foofoo' } } }
175
175
 
176
176
  it 'respects custom module name transformation' do
177
- expect_no_violations(<<-RUBY, filename: 'foofoo/some/class/bar_spec.rb')
177
+ expect_no_offenses(<<-RUBY, 'foofoo/some/class/bar_spec.rb')
178
178
  describe FooFoo::Some::Class, '#bar' do; end
179
179
  RUBY
180
180
  end
181
181
 
182
182
  it 'ignores routing specs' do
183
- expect_no_violations(<<-RUBY, filename: 'foofoo/some/class/bar_spec.rb')
183
+ expect_no_offenses(<<-RUBY, 'foofoo/some/class/bar_spec.rb')
184
184
  describe MyController, "#foo", type: :routing do; end
185
185
  RUBY
186
186
  end
@@ -190,7 +190,7 @@ RSpec.describe RuboCop::Cop::RSpec::FilePath, :config do
190
190
  let(:cop_config) { { 'IgnoreMethods' => true } }
191
191
 
192
192
  it 'does not care about the described method' do
193
- expect_no_violations(<<-RUBY, filename: 'my_class_spec.rb')
193
+ expect_no_offenses(<<-RUBY, 'my_class_spec.rb')
194
194
  describe MyClass, '#look_here_a_method' do; end
195
195
  RUBY
196
196
  end