rubocop-rspec 1.32.0 → 1.33.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 +11 -0
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/config/default.yml +6 -0
- data/lib/rubocop-rspec.rb +3 -0
- data/lib/rubocop/cop/rspec/align_left_let_brace.rb +1 -1
- data/lib/rubocop/cop/rspec/align_right_let_brace.rb +1 -1
- data/lib/rubocop/cop/rspec/any_instance.rb +3 -1
- data/lib/rubocop/cop/rspec/around_block.rb +4 -2
- data/lib/rubocop/cop/rspec/be.rb +4 -2
- data/lib/rubocop/cop/rspec/be_eql.rb +3 -1
- data/lib/rubocop/cop/rspec/before_after_all.rb +1 -1
- data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +5 -3
- data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +3 -3
- data/lib/rubocop/cop/rspec/context_wording.rb +2 -2
- data/lib/rubocop/cop/rspec/describe_class.rb +4 -4
- data/lib/rubocop/cop/rspec/describe_method.rb +2 -2
- data/lib/rubocop/cop/rspec/describe_symbol.rb +2 -2
- data/lib/rubocop/cop/rspec/described_class.rb +3 -3
- data/lib/rubocop/cop/rspec/dialect.rb +76 -0
- data/lib/rubocop/cop/rspec/empty_example_group.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_example_group.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_final_let.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_hook.rb +1 -1
- data/lib/rubocop/cop/rspec/empty_line_after_subject.rb +1 -1
- data/lib/rubocop/cop/rspec/example_length.rb +1 -1
- data/lib/rubocop/cop/rspec/example_without_description.rb +2 -2
- data/lib/rubocop/cop/rspec/example_wording.rb +2 -2
- data/lib/rubocop/cop/rspec/expect_actual.rb +1 -1
- data/lib/rubocop/cop/rspec/expect_change.rb +2 -2
- data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -1
- data/lib/rubocop/cop/rspec/expect_output.rb +1 -1
- data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +21 -40
- data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +2 -2
- data/lib/rubocop/cop/rspec/file_path.rb +2 -2
- data/lib/rubocop/cop/rspec/focus.rb +3 -3
- data/lib/rubocop/cop/rspec/hook_argument.rb +4 -6
- data/lib/rubocop/cop/rspec/hooks_before_examples.rb +2 -5
- data/lib/rubocop/cop/rspec/implicit_expect.rb +2 -2
- data/lib/rubocop/cop/rspec/implicit_subject.rb +1 -1
- data/lib/rubocop/cop/rspec/instance_spy.rb +1 -1
- data/lib/rubocop/cop/rspec/instance_variable.rb +1 -1
- data/lib/rubocop/cop/rspec/invalid_predicate_matcher.rb +4 -2
- data/lib/rubocop/cop/rspec/it_behaves_like.rb +1 -1
- data/lib/rubocop/cop/rspec/iterated_expectation.rb +3 -1
- data/lib/rubocop/cop/rspec/leading_subject.rb +1 -2
- data/lib/rubocop/cop/rspec/let_before_examples.rb +2 -5
- data/lib/rubocop/cop/rspec/let_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/message_chain.rb +3 -1
- data/lib/rubocop/cop/rspec/message_expectation.rb +1 -1
- data/lib/rubocop/cop/rspec/message_spies.rb +3 -4
- data/lib/rubocop/cop/rspec/missing_example_group_argument.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_subjects.rb +6 -2
- data/lib/rubocop/cop/rspec/named_subject.rb +1 -1
- data/lib/rubocop/cop/rspec/nested_groups.rb +3 -4
- data/lib/rubocop/cop/rspec/not_to_not.rb +3 -1
- data/lib/rubocop/cop/rspec/overwriting_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/pending.rb +3 -3
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +17 -14
- data/lib/rubocop/cop/rspec/rails/http_status.rb +2 -2
- data/lib/rubocop/cop/rspec/receive_counts.rb +5 -6
- data/lib/rubocop/cop/rspec/receive_never.rb +4 -7
- data/lib/rubocop/cop/rspec/repeated_description.rb +3 -1
- data/lib/rubocop/cop/rspec/repeated_example.rb +3 -1
- data/lib/rubocop/cop/rspec/return_from_stub.rb +2 -2
- data/lib/rubocop/cop/rspec/scattered_let.rb +1 -1
- data/lib/rubocop/cop/rspec/scattered_setup.rb +1 -1
- data/lib/rubocop/cop/rspec/shared_context.rb +2 -2
- data/lib/rubocop/cop/rspec/shared_examples.rb +7 -7
- data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +3 -1
- data/lib/rubocop/cop/rspec/subject_stub.rb +1 -1
- data/lib/rubocop/cop/rspec/unspecified_exception.rb +5 -3
- data/lib/rubocop/cop/rspec/verified_doubles.rb +2 -2
- data/lib/rubocop/cop/rspec/void_expect.rb +1 -1
- data/lib/rubocop/cop/rspec/yield.rb +2 -4
- data/lib/rubocop/cop/rspec_cops.rb +3 -0
- data/lib/rubocop/rspec.rb +2 -0
- data/lib/rubocop/rspec/blank_line_separation.rb +3 -1
- data/lib/rubocop/rspec/config_formatter.rb +3 -1
- data/lib/rubocop/rspec/description_extractor.rb +3 -1
- data/lib/rubocop/rspec/factory_bot.rb +58 -0
- data/lib/rubocop/rspec/final_end_location.rb +2 -0
- data/lib/rubocop/rspec/inject.rb +2 -0
- data/lib/rubocop/rspec/language.rb +9 -2
- data/lib/rubocop/rspec/top_level_describe.rb +2 -0
- data/lib/rubocop/rspec/version.rb +1 -1
- data/rubocop-rspec.gemspec +3 -1
- data/spec/project/changelog_spec.rb +2 -0
- data/spec/project/default_config_spec.rb +2 -0
- data/spec/project/project_requires_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +22 -37
- data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +21 -36
- data/spec/rubocop/cop/rspec/any_instance_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/around_block_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/be_eql_spec.rb +25 -4
- data/spec/rubocop/cop/rspec/be_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/before_after_all_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/context_wording_spec.rb +32 -0
- data/spec/rubocop/cop/rspec/describe_class_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/describe_method_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/described_class_spec.rb +4 -1
- data/spec/rubocop/cop/rspec/dialect_spec.rb +78 -0
- data/spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb +40 -21
- data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +77 -69
- data/spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb +24 -19
- data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +16 -19
- data/spec/rubocop/cop/rspec/example_length_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/example_without_description_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/example_wording_spec.rb +45 -24
- data/spec/rubocop/cop/rspec/expect_change_spec.rb +22 -14
- data/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb +36 -0
- data/spec/rubocop/cop/rspec/factory_bot/create_list_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/file_path_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/focus_spec.rb +2 -2
- data/spec/rubocop/cop/rspec/hook_argument_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/hooks_before_examples_spec.rb +47 -32
- data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +20 -19
- data/spec/rubocop/cop/rspec/implicit_subject_spec.rb +56 -68
- data/spec/rubocop/cop/rspec/instance_spy_spec.rb +16 -15
- data/spec/rubocop/cop/rspec/instance_variable_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +10 -12
- data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/leading_subject_spec.rb +31 -47
- data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +27 -26
- data/spec/rubocop/cop/rspec/message_chain_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +24 -37
- data/spec/rubocop/cop/rspec/not_to_not_spec.rb +22 -32
- data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/pending_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/receive_counts_spec.rb +47 -8
- data/spec/rubocop/cop/rspec/receive_never_spec.rb +16 -4
- data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +95 -72
- data/spec/rubocop/cop/rspec/scattered_let_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/shared_context_spec.rb +29 -34
- data/spec/rubocop/cop/rspec/shared_examples_spec.rb +16 -34
- data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +44 -48
- data/spec/rubocop/cop/rspec/unspecified_exception_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/void_expect_spec.rb +2 -0
- data/spec/rubocop/cop/rspec/yield_spec.rb +22 -21
- data/spec/rubocop/rspec/config_formatter_spec.rb +2 -0
- data/spec/rubocop/rspec/description_extractor_spec.rb +2 -0
- data/spec/rubocop/rspec/language/selector_set_spec.rb +2 -0
- data/spec/rubocop/rspec/util/one_spec.rb +2 -0
- data/spec/rubocop/rspec/wording_spec.rb +2 -0
- data/spec/shared/autocorrect_behavior.rb +2 -0
- data/spec/shared/detects_style_behavior.rb +2 -0
- data/spec/shared/smoke_test_examples.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/expect_offense.rb +3 -1
- metadata +8 -4
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe RuboCop::Cop::RSpec::Yield do
|
2
4
|
subject(:cop) { described_class.new }
|
3
5
|
|
@@ -6,6 +8,10 @@ RSpec.describe RuboCop::Cop::RSpec::Yield do
|
|
6
8
|
allow(foo).to receive(:bar) { |&block| block.call }
|
7
9
|
^^^^^^^^^^^^^^^^^^^^^^^ Use `.and_yield`.
|
8
10
|
RUBY
|
11
|
+
|
12
|
+
expect_correction(<<-RUBY)
|
13
|
+
allow(foo).to receive(:bar).and_yield
|
14
|
+
RUBY
|
9
15
|
end
|
10
16
|
|
11
17
|
it 'flags multiple `block.call`' do
|
@@ -16,6 +22,10 @@ RSpec.describe RuboCop::Cop::RSpec::Yield do
|
|
16
22
|
block.call
|
17
23
|
end
|
18
24
|
RUBY
|
25
|
+
|
26
|
+
expect_correction(<<-RUBY)
|
27
|
+
allow(foo).to receive(:bar).and_yield.and_yield
|
28
|
+
RUBY
|
19
29
|
end
|
20
30
|
|
21
31
|
it 'flags `block.call` with arguments' do
|
@@ -23,6 +33,10 @@ RSpec.describe RuboCop::Cop::RSpec::Yield do
|
|
23
33
|
allow(foo).to receive(:bar) { |&block| block.call(1, 2) }
|
24
34
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `.and_yield`.
|
25
35
|
RUBY
|
36
|
+
|
37
|
+
expect_correction(<<-RUBY)
|
38
|
+
allow(foo).to receive(:bar).and_yield(1, 2)
|
39
|
+
RUBY
|
26
40
|
end
|
27
41
|
|
28
42
|
it 'flags multiple `block.call` with arguments' do
|
@@ -33,6 +47,10 @@ RSpec.describe RuboCop::Cop::RSpec::Yield do
|
|
33
47
|
block.call(2)
|
34
48
|
end
|
35
49
|
RUBY
|
50
|
+
|
51
|
+
expect_correction(<<-RUBY)
|
52
|
+
allow(foo).to receive(:bar).and_yield(1).and_yield(2)
|
53
|
+
RUBY
|
36
54
|
end
|
37
55
|
|
38
56
|
it 'flags `block.call` when `receive` is chained' do
|
@@ -40,6 +58,10 @@ RSpec.describe RuboCop::Cop::RSpec::Yield do
|
|
40
58
|
allow(foo).to receive(:bar).with(anything) { |&block| block.call }
|
41
59
|
^^^^^^^^^^^^^^^^^^^^^^^ Use `.and_yield`.
|
42
60
|
RUBY
|
61
|
+
|
62
|
+
expect_correction(<<-RUBY)
|
63
|
+
allow(foo).to receive(:bar).with(anything).and_yield
|
64
|
+
RUBY
|
43
65
|
end
|
44
66
|
|
45
67
|
it 'ignores `receive` with no block arguments' do
|
@@ -56,25 +78,4 @@ RSpec.describe RuboCop::Cop::RSpec::Yield do
|
|
56
78
|
end
|
57
79
|
RUBY
|
58
80
|
end
|
59
|
-
|
60
|
-
include_examples 'autocorrect',
|
61
|
-
'allow(foo).to receive(:bar) { |&block| block.call }',
|
62
|
-
'allow(foo).to receive(:bar).and_yield'
|
63
|
-
|
64
|
-
include_examples 'autocorrect',
|
65
|
-
'allow(foo).to receive(:bar) { |&block| block.call(1, 2) }',
|
66
|
-
'allow(foo).to receive(:bar).and_yield(1, 2)'
|
67
|
-
|
68
|
-
bad_code = <<-RUBY
|
69
|
-
allow(foo).to receive(:bar) do |&block|
|
70
|
-
block.call(1)
|
71
|
-
block.call(2)
|
72
|
-
end
|
73
|
-
RUBY
|
74
|
-
|
75
|
-
good_code = <<-RUBY
|
76
|
-
allow(foo).to receive(:bar).and_yield(1).and_yield(2)
|
77
|
-
RUBY
|
78
|
-
|
79
|
-
include_examples 'autocorrect', bad_code, good_code
|
80
81
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# rubocop-rspec gem extension of RuboCop's ExpectOffense module.
|
2
4
|
#
|
3
5
|
# This mixin is the same as rubocop's ExpectOffense except the default
|
@@ -5,7 +7,7 @@
|
|
5
7
|
module ExpectOffense
|
6
8
|
include RuboCop::RSpec::ExpectOffense
|
7
9
|
|
8
|
-
DEFAULT_FILENAME = 'example_spec.rb'
|
10
|
+
DEFAULT_FILENAME = 'example_spec.rb'
|
9
11
|
|
10
12
|
def expect_offense(source, filename = DEFAULT_FILENAME)
|
11
13
|
super
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Backus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubocop
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/rubocop/cop/rspec/describe_method.rb
|
132
132
|
- lib/rubocop/cop/rspec/describe_symbol.rb
|
133
133
|
- lib/rubocop/cop/rspec/described_class.rb
|
134
|
+
- lib/rubocop/cop/rspec/dialect.rb
|
134
135
|
- lib/rubocop/cop/rspec/empty_example_group.rb
|
135
136
|
- lib/rubocop/cop/rspec/empty_line_after_example_group.rb
|
136
137
|
- lib/rubocop/cop/rspec/empty_line_after_final_let.rb
|
@@ -197,6 +198,7 @@ files:
|
|
197
198
|
- lib/rubocop/rspec/description_extractor.rb
|
198
199
|
- lib/rubocop/rspec/example.rb
|
199
200
|
- lib/rubocop/rspec/example_group.rb
|
201
|
+
- lib/rubocop/rspec/factory_bot.rb
|
200
202
|
- lib/rubocop/rspec/final_end_location.rb
|
201
203
|
- lib/rubocop/rspec/hook.rb
|
202
204
|
- lib/rubocop/rspec/inject.rb
|
@@ -226,6 +228,7 @@ files:
|
|
226
228
|
- spec/rubocop/cop/rspec/describe_method_spec.rb
|
227
229
|
- spec/rubocop/cop/rspec/describe_symbol_spec.rb
|
228
230
|
- spec/rubocop/cop/rspec/described_class_spec.rb
|
231
|
+
- spec/rubocop/cop/rspec/dialect_spec.rb
|
229
232
|
- spec/rubocop/cop/rspec/empty_example_group_spec.rb
|
230
233
|
- spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb
|
231
234
|
- spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb
|
@@ -314,14 +317,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
314
317
|
requirements:
|
315
318
|
- - ">="
|
316
319
|
- !ruby/object:Gem::Version
|
317
|
-
version: 2.
|
320
|
+
version: 2.3.0
|
318
321
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
322
|
requirements:
|
320
323
|
- - ">="
|
321
324
|
- !ruby/object:Gem::Version
|
322
325
|
version: '0'
|
323
326
|
requirements: []
|
324
|
-
rubygems_version: 3.0.
|
327
|
+
rubygems_version: 3.0.3
|
325
328
|
signing_key:
|
326
329
|
specification_version: 4
|
327
330
|
summary: Code style checking for RSpec files
|
@@ -344,6 +347,7 @@ test_files:
|
|
344
347
|
- spec/rubocop/cop/rspec/describe_method_spec.rb
|
345
348
|
- spec/rubocop/cop/rspec/describe_symbol_spec.rb
|
346
349
|
- spec/rubocop/cop/rspec/described_class_spec.rb
|
350
|
+
- spec/rubocop/cop/rspec/dialect_spec.rb
|
347
351
|
- spec/rubocop/cop/rspec/empty_example_group_spec.rb
|
348
352
|
- spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb
|
349
353
|
- spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb
|