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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/Gemfile +0 -1
- data/config/default.yml +105 -0
- data/lib/rubocop-rspec.rb +27 -0
- data/lib/rubocop/cop/rspec/align_left_let_brace.rb +51 -0
- data/lib/rubocop/cop/rspec/align_right_let_brace.rb +51 -0
- data/lib/rubocop/cop/rspec/any_instance.rb +1 -1
- data/lib/rubocop/cop/rspec/cop.rb +4 -2
- data/lib/rubocop/cop/rspec/expect_in_hook.rb +61 -0
- data/lib/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically.rb +84 -0
- data/lib/rubocop/cop/rspec/hook_argument.rb +11 -5
- data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +42 -0
- data/lib/rubocop/cop/rspec/let_before_examples.rb +66 -0
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +3 -5
- data/lib/rubocop/cop/rspec/multiple_subjects.rb +80 -0
- data/lib/rubocop/cop/rspec/named_subject.rb +5 -6
- data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +337 -0
- data/lib/rubocop/cop/rspec/return_from_stub.rb +83 -0
- data/lib/rubocop/cop/rspec/void_expect.rb +52 -0
- data/lib/rubocop/rspec/align_let_brace.rb +64 -0
- data/lib/rubocop/rspec/config_formatter.rb +7 -4
- data/lib/rubocop/rspec/description_extractor.rb +2 -2
- data/lib/rubocop/rspec/example_group.rb +25 -2
- data/lib/rubocop/rspec/factory_girl.rb +7 -0
- data/lib/rubocop/rspec/language.rb +6 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- data/rubocop-rspec.gemspec +1 -4
- data/spec/project/default_config_spec.rb +8 -4
- data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +62 -0
- data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +62 -0
- data/spec/rubocop/cop/rspec/any_instance_spec.rb +3 -3
- data/spec/rubocop/cop/rspec/around_block_spec.rb +11 -11
- data/spec/rubocop/cop/rspec/be_eql_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/before_after_all_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/cop_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/describe_class_spec.rb +18 -18
- data/spec/rubocop/cop/rspec/describe_method_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +6 -6
- data/spec/rubocop/cop/rspec/described_class_spec.rb +18 -18
- data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +9 -9
- data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/example_length_spec.rb +6 -6
- data/spec/rubocop/cop/rspec/example_wording_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/expect_actual_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +79 -0
- data/spec/rubocop/cop/rspec/expect_output_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/factory_girl/dynamic_attribute_defined_statically_spec.rb +87 -0
- data/spec/rubocop/cop/rspec/file_path_spec.rb +29 -29
- data/spec/rubocop/cop/rspec/focus_spec.rb +6 -6
- data/spec/rubocop/cop/rspec/hook_argument_spec.rb +35 -23
- data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/instance_spy_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/instance_variable_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +37 -0
- data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +8 -8
- data/spec/rubocop/cop/rspec/leading_subject_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +83 -0
- data/spec/rubocop/cop/rspec/let_setup_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/message_expectation_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/message_spies_spec.rb +18 -18
- data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +3 -3
- data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +45 -9
- data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +96 -0
- data/spec/rubocop/cop/rspec/named_subject_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/nested_groups_spec.rb +3 -3
- data/spec/rubocop/cop/rspec/not_to_not_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +4 -4
- data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +335 -0
- data/spec/rubocop/cop/rspec/repeated_description_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/repeated_example_spec.rb +5 -5
- data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +85 -0
- data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +8 -8
- data/spec/rubocop/cop/rspec/shared_context_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +10 -10
- data/spec/rubocop/cop/rspec/subject_stub_spec.rb +9 -9
- data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +7 -7
- data/spec/rubocop/cop/rspec/void_expect_spec.rb +47 -0
- data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/expect_offense.rb +17 -0
- metadata +39 -51
- data/spec/expect_violation/expectation_spec.rb +0 -85
- data/spec/support/expect_violation.rb +0 -170
@@ -3,7 +3,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
3
3
|
|
4
4
|
context 'when no value is yielded' do
|
5
5
|
it 'registers an offense' do
|
6
|
-
|
6
|
+
expect_offense(<<-RUBY)
|
7
7
|
around do
|
8
8
|
^^^^^^^^^ Test object should be passed to around block.
|
9
9
|
do_something
|
@@ -14,7 +14,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
14
14
|
|
15
15
|
context 'when the hook is scoped with a symbol' do
|
16
16
|
it 'registers an offense' do
|
17
|
-
|
17
|
+
expect_offense(<<-RUBY)
|
18
18
|
around(:each) do
|
19
19
|
^^^^^^^^^^^^^^^^ Test object should be passed to around block.
|
20
20
|
do_something
|
@@ -25,7 +25,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
25
25
|
|
26
26
|
context 'when the yielded value is unused' do
|
27
27
|
it 'registers an offense' do
|
28
|
-
|
28
|
+
expect_offense(<<-RUBY)
|
29
29
|
around do |test|
|
30
30
|
^^^^ You should call `test.call` or `test.run`.
|
31
31
|
do_something
|
@@ -36,7 +36,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
36
36
|
|
37
37
|
context 'when two values are yielded and the first is unused' do
|
38
38
|
it 'registers an offense for the first argument' do
|
39
|
-
|
39
|
+
expect_offense(<<-RUBY)
|
40
40
|
around do |test, unused|
|
41
41
|
^^^^ You should call `test.call` or `test.run`.
|
42
42
|
unused.run
|
@@ -47,7 +47,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
47
47
|
|
48
48
|
context 'when the yielded value is referenced but not used' do
|
49
49
|
it 'registers an offense' do
|
50
|
-
|
50
|
+
expect_offense(<<-RUBY)
|
51
51
|
around do |test|
|
52
52
|
^^^^ You should call `test.call` or `test.run`.
|
53
53
|
test
|
@@ -58,7 +58,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
58
58
|
|
59
59
|
context 'when a method other than #run or #call is called' do
|
60
60
|
it 'registers an offense' do
|
61
|
-
|
61
|
+
expect_offense(<<-RUBY)
|
62
62
|
around do |test|
|
63
63
|
^^^^ You should call `test.call` or `test.run`.
|
64
64
|
test.inspect
|
@@ -69,7 +69,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
69
69
|
|
70
70
|
context 'when #run is called' do
|
71
71
|
it 'does not register an offense' do
|
72
|
-
|
72
|
+
expect_no_offenses(<<-RUBY)
|
73
73
|
around do |test|
|
74
74
|
test.run
|
75
75
|
end
|
@@ -79,7 +79,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
79
79
|
|
80
80
|
context 'when #call is called' do
|
81
81
|
it 'does not register an offense' do
|
82
|
-
|
82
|
+
expect_no_offenses(<<-RUBY)
|
83
83
|
around do |test|
|
84
84
|
test.call
|
85
85
|
end
|
@@ -89,7 +89,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
89
89
|
|
90
90
|
context 'when used as a block arg' do
|
91
91
|
it 'does not register an offense' do
|
92
|
-
|
92
|
+
expect_no_offenses(<<-RUBY)
|
93
93
|
around do |test|
|
94
94
|
1.times(&test)
|
95
95
|
end
|
@@ -99,7 +99,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
99
99
|
|
100
100
|
context 'when passed to another method' do
|
101
101
|
it 'does not register an offense' do
|
102
|
-
|
102
|
+
expect_no_offenses(<<-RUBY)
|
103
103
|
around do |test|
|
104
104
|
something_that_might_run_test(test, another_arg)
|
105
105
|
end
|
@@ -109,7 +109,7 @@ RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
|
|
109
109
|
|
110
110
|
context 'when yielded to another block' do
|
111
111
|
it 'does not register an offense' do
|
112
|
-
|
112
|
+
expect_no_offenses(<<-RUBY)
|
113
113
|
around do |test|
|
114
114
|
foo { yield(some_arg, test) }
|
115
115
|
end
|
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeEql do
|
|
2
2
|
subject(:cop) { described_class.new }
|
3
3
|
|
4
4
|
it 'registers an offense for `eql` when argument is a boolean' do
|
5
|
-
|
5
|
+
expect_offense(<<-RUBY)
|
6
6
|
it { expect(foo).to eql(true) }
|
7
7
|
^^^ Prefer `be` over `eql`.
|
8
8
|
it { expect(foo).to eql(false) }
|
@@ -11,7 +11,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeEql do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'registers an offense for `eql` when argument is an integer' do
|
14
|
-
|
14
|
+
expect_offense(<<-RUBY)
|
15
15
|
it { expect(foo).to eql(0) }
|
16
16
|
^^^ Prefer `be` over `eql`.
|
17
17
|
it { expect(foo).to eql(123) }
|
@@ -20,7 +20,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeEql do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'registers an offense for `eql` when argument is a float' do
|
23
|
-
|
23
|
+
expect_offense(<<-RUBY)
|
24
24
|
it { expect(foo).to eql(1.0) }
|
25
25
|
^^^ Prefer `be` over `eql`.
|
26
26
|
it { expect(foo).to eql(1.23) }
|
@@ -29,27 +29,27 @@ RSpec.describe RuboCop::Cop::RSpec::BeEql do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'registers an offense for `eql` when argument is a symbol' do
|
32
|
-
|
32
|
+
expect_offense(<<-RUBY)
|
33
33
|
it { expect(foo).to eql(:foo) }
|
34
34
|
^^^ Prefer `be` over `eql`.
|
35
35
|
RUBY
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'registers an offense for `eql` when argument is nil' do
|
39
|
-
|
39
|
+
expect_offense(<<-RUBY)
|
40
40
|
it { expect(foo).to eql(nil) }
|
41
41
|
^^^ Prefer `be` over `eql`.
|
42
42
|
RUBY
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'does not register an offense for `eql` when argument is a string' do
|
46
|
-
|
46
|
+
expect_no_offenses(<<-RUBY)
|
47
47
|
it { expect(foo).to eql('foo') }
|
48
48
|
RUBY
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'does not register an offense for `eql` when expectation is negated' do
|
52
|
-
|
52
|
+
expect_no_offenses(<<-RUBY)
|
53
53
|
it { expect(foo).to_not eql(1) }
|
54
54
|
RUBY
|
55
55
|
end
|
@@ -10,7 +10,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll, :config do
|
|
10
10
|
|
11
11
|
context 'when using before all' do
|
12
12
|
it 'registers an offense' do
|
13
|
-
|
13
|
+
expect_offense(<<-RUBY)
|
14
14
|
before(:all) { do_something }
|
15
15
|
^^^^^^^^^^^^ #{message('before(:all)')}
|
16
16
|
before(:context) { do_something }
|
@@ -21,7 +21,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll, :config do
|
|
21
21
|
|
22
22
|
context 'when using after all' do
|
23
23
|
it 'registers an offense' do
|
24
|
-
|
24
|
+
expect_offense(<<-RUBY)
|
25
25
|
after(:all) { do_something }
|
26
26
|
^^^^^^^^^^^ #{message('after(:all)')}
|
27
27
|
after(:context) { do_something }
|
@@ -32,7 +32,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll, :config do
|
|
32
32
|
|
33
33
|
context 'when using before each' do
|
34
34
|
it 'does not register an offense' do
|
35
|
-
|
35
|
+
expect_no_offenses(<<-RUBY)
|
36
36
|
before(:each) { do_something }
|
37
37
|
before(:example) { do_something }
|
38
38
|
RUBY
|
@@ -41,7 +41,7 @@ RSpec.describe RuboCop::Cop::RSpec::BeforeAfterAll, :config do
|
|
41
41
|
|
42
42
|
context 'when using after each' do
|
43
43
|
it 'does not register an offense' do
|
44
|
-
|
44
|
+
expect_no_offenses(<<-RUBY)
|
45
45
|
after(:each) { do_something }
|
46
46
|
after(:example) { do_something }
|
47
47
|
RUBY
|
@@ -38,14 +38,14 @@ RSpec.describe RuboCop::Cop::RSpec::Cop do
|
|
38
38
|
|
39
39
|
context 'when the source path ends with `_spec.rb`' do
|
40
40
|
it 'registers an offense' do
|
41
|
-
|
41
|
+
expect_offense(<<-RUBY, 'foo_spec.rb')
|
42
42
|
foo(1)
|
43
43
|
^^^^^^ I flag everything
|
44
44
|
RUBY
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'ignores the file if it is ignored' do
|
48
|
-
|
48
|
+
expect_no_offenses(<<-RUBY, 'bar_spec.rb')
|
49
49
|
foo(1)
|
50
50
|
RUBY
|
51
51
|
end
|
@@ -53,7 +53,7 @@ RSpec.describe RuboCop::Cop::RSpec::Cop do
|
|
53
53
|
|
54
54
|
context 'when the source path contains `/spec/`' do
|
55
55
|
it 'registers an offense' do
|
56
|
-
|
56
|
+
expect_offense(<<-RUBY, '/spec/support/thing.rb')
|
57
57
|
foo(1)
|
58
58
|
^^^^^^ I flag everything
|
59
59
|
RUBY
|
@@ -62,7 +62,7 @@ RSpec.describe RuboCop::Cop::RSpec::Cop do
|
|
62
62
|
|
63
63
|
context 'when the source path starts with `spec/`' do
|
64
64
|
it 'registers an offense' do
|
65
|
-
|
65
|
+
expect_offense(<<-RUBY, 'spec/support/thing.rb')
|
66
66
|
foo(1)
|
67
67
|
^^^^^^ I flag everything
|
68
68
|
RUBY
|
@@ -71,13 +71,13 @@ RSpec.describe RuboCop::Cop::RSpec::Cop do
|
|
71
71
|
|
72
72
|
context 'when the file is a source file without "spec" in the name' do
|
73
73
|
it 'ignores the source when the path is not a spec file' do
|
74
|
-
|
74
|
+
expect_no_offenses(<<-RUBY, 'foo.rb')
|
75
75
|
foo(1)
|
76
76
|
RUBY
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'ignores the source when the path is not a specified pattern' do
|
80
|
-
|
80
|
+
expect_no_offenses(<<-RUBY, 'foo_test.rb')
|
81
81
|
foo(1)
|
82
82
|
RUBY
|
83
83
|
end
|
@@ -89,7 +89,7 @@ RSpec.describe RuboCop::Cop::RSpec::Cop do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'registers offenses when the path matches a custom specified pattern' do
|
92
|
-
|
92
|
+
expect_offense(<<-RUBY, 'foo_test.rb')
|
93
93
|
foo(1)
|
94
94
|
^^^^^^ I flag everything
|
95
95
|
RUBY
|
@@ -2,7 +2,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
2
2
|
subject(:cop) { described_class.new }
|
3
3
|
|
4
4
|
it 'checks first-line describe statements' do
|
5
|
-
|
5
|
+
expect_offense(<<-RUBY)
|
6
6
|
describe "bad describe" do
|
7
7
|
^^^^^^^^^^^^^^ The first argument to describe should be the class or module being tested.
|
8
8
|
end
|
@@ -10,14 +10,14 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'supports RSpec.describe' do
|
13
|
-
|
13
|
+
expect_no_offenses(<<-RUBY)
|
14
14
|
RSpec.describe Foo do
|
15
15
|
end
|
16
16
|
RUBY
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'checks describe statements after a require' do
|
20
|
-
|
20
|
+
expect_offense(<<-RUBY)
|
21
21
|
require 'spec_helper'
|
22
22
|
describe "bad describe" do
|
23
23
|
^^^^^^^^^^^^^^ The first argument to describe should be the class or module being tested.
|
@@ -26,7 +26,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'checks highlights the first argument of a describe' do
|
29
|
-
|
29
|
+
expect_offense(<<-RUBY)
|
30
30
|
describe "bad describe", "blah blah" do
|
31
31
|
^^^^^^^^^^^^^^ The first argument to describe should be the class or module being tested.
|
32
32
|
end
|
@@ -34,7 +34,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'ignores nested describe statements' do
|
37
|
-
|
37
|
+
expect_no_offenses(<<-RUBY)
|
38
38
|
describe Some::Class do
|
39
39
|
describe "bad describe" do
|
40
40
|
end
|
@@ -43,28 +43,28 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'ignores request specs' do
|
46
|
-
|
46
|
+
expect_no_offenses(<<-RUBY)
|
47
47
|
describe 'my new feature', type: :request do
|
48
48
|
end
|
49
49
|
RUBY
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'ignores feature specs' do
|
53
|
-
|
53
|
+
expect_no_offenses(<<-RUBY)
|
54
54
|
describe 'my new feature', type: :feature do
|
55
55
|
end
|
56
56
|
RUBY
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'ignores feature specs when RSpec.describe is used' do
|
60
|
-
|
60
|
+
expect_no_offenses(<<-RUBY)
|
61
61
|
RSpec.describe 'my new feature', type: :feature do
|
62
62
|
end
|
63
63
|
RUBY
|
64
64
|
end
|
65
65
|
|
66
66
|
it 'flags specs with non :type metadata' do
|
67
|
-
|
67
|
+
expect_offense(<<-RUBY)
|
68
68
|
describe 'my new feature', foo: :feature do
|
69
69
|
^^^^^^^^^^^^^^^^ The first argument to describe should be the class or module being tested.
|
70
70
|
end
|
@@ -72,7 +72,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'flags normal metadata in describe' do
|
75
|
-
|
75
|
+
expect_offense(<<-RUBY)
|
76
76
|
describe 'my new feature', blah, type: :wow do
|
77
77
|
^^^^^^^^^^^^^^^^ The first argument to describe should be the class or module being tested.
|
78
78
|
end
|
@@ -80,39 +80,39 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'ignores feature specs - also with complex options' do
|
83
|
-
|
83
|
+
expect_no_offenses(<<-RUBY)
|
84
84
|
describe 'my new feature', :test, :type => :feature, :foo => :bar do
|
85
85
|
end
|
86
86
|
RUBY
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'ignores an empty describe' do
|
90
|
-
|
90
|
+
expect_no_offenses(<<-RUBY)
|
91
91
|
describe do
|
92
92
|
end
|
93
93
|
RUBY
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'ignores routing specs' do
|
97
|
-
|
97
|
+
expect_no_offenses(<<-RUBY)
|
98
98
|
describe 'my new route', type: :routing do
|
99
99
|
end
|
100
100
|
RUBY
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'ignores view specs' do
|
104
|
-
|
104
|
+
expect_no_offenses(<<-RUBY)
|
105
105
|
describe 'widgets/index', type: :view do
|
106
106
|
end
|
107
107
|
RUBY
|
108
108
|
end
|
109
109
|
|
110
110
|
it "doesn't blow up on single-line describes" do
|
111
|
-
|
111
|
+
expect_no_offenses('describe Some::Class')
|
112
112
|
end
|
113
113
|
|
114
114
|
it "doesn't flag top level describe in a shared example" do
|
115
|
-
|
115
|
+
expect_no_offenses(<<-RUBY)
|
116
116
|
shared_examples 'Common::Interface' do
|
117
117
|
describe '#public_interface' do
|
118
118
|
it 'conforms to interface' do
|
@@ -124,7 +124,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
it "doesn't flag top level describe in a shared context" do
|
127
|
-
|
127
|
+
expect_no_offenses(<<-RUBY)
|
128
128
|
RSpec.shared_context 'Common::Interface' do
|
129
129
|
describe '#public_interface' do
|
130
130
|
it 'conforms to interface' do
|
@@ -136,7 +136,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeClass do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it "doesn't flag top level describe in an unnamed shared context" do
|
139
|
-
|
139
|
+
expect_no_offenses(<<-RUBY)
|
140
140
|
shared_context do
|
141
141
|
describe '#public_interface' do
|
142
142
|
it 'conforms to interface' do
|
@@ -2,11 +2,11 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeMethod do
|
|
2
2
|
subject(:cop) { described_class.new }
|
3
3
|
|
4
4
|
it 'ignores describes with only a class' do
|
5
|
-
|
5
|
+
expect_no_offenses('describe Some::Class do; end')
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'enforces non-method names' do
|
9
|
-
|
9
|
+
expect_offense(<<-RUBY)
|
10
10
|
describe Some::Class, 'nope', '.incorrect_usage' do
|
11
11
|
^^^^^^ The second argument to describe should be the method being tested. '#instance' or '.class'.
|
12
12
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeMethod do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'skips methods starting with a . or #' do
|
17
|
-
|
17
|
+
expect_no_offenses(<<-RUBY)
|
18
18
|
describe Some::Class, '.asdf' do
|
19
19
|
end
|
20
20
|
|
@@ -24,7 +24,7 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeMethod do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'skips specs not having a string second argument' do
|
27
|
-
|
27
|
+
expect_no_offenses(<<-RUBY)
|
28
28
|
describe Some::Class, :config do
|
29
29
|
end
|
30
30
|
RUBY
|
@@ -2,28 +2,28 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeSymbol do
|
|
2
2
|
subject(:cop) { described_class.new }
|
3
3
|
|
4
4
|
it 'flags violations for `describe :symbol`' do
|
5
|
-
|
5
|
+
expect_offense(<<-RUBY)
|
6
6
|
describe(:some_method) { }
|
7
7
|
^^^^^^^^^^^^ Avoid describing symbols.
|
8
8
|
RUBY
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'flags violations for `describe :symbol` with multiple arguments' do
|
12
|
-
|
12
|
+
expect_offense(<<-RUBY)
|
13
13
|
describe(:some_method, "description") { }
|
14
14
|
^^^^^^^^^^^^ Avoid describing symbols.
|
15
15
|
RUBY
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'flags violations for `RSpec.describe :symbol`' do
|
19
|
-
|
19
|
+
expect_offense(<<-RUBY)
|
20
20
|
RSpec.describe(:some_method, "description") { }
|
21
21
|
^^^^^^^^^^^^ Avoid describing symbols.
|
22
22
|
RUBY
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'flags violations for a nested `describe`' do
|
26
|
-
|
26
|
+
expect_offense(<<-RUBY)
|
27
27
|
RSpec.describe Foo do
|
28
28
|
describe :to_s do
|
29
29
|
^^^^^ Avoid describing symbols.
|
@@ -33,10 +33,10 @@ RSpec.describe RuboCop::Cop::RSpec::DescribeSymbol do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'does not flag non-Symbol arguments' do
|
36
|
-
|
36
|
+
expect_no_offenses('describe("#some_method") { }')
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'does not flag `context :symbol`' do
|
40
|
-
|
40
|
+
expect_no_offenses('context(:some_method) { }')
|
41
41
|
end
|
42
42
|
end
|