rubocop-rspec 2.29.1 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +92 -3
- data/README.md +21 -5
- data/config/default.yml +64 -269
- data/config/obsoletion.yml +20 -21
- data/lib/rubocop/cop/rspec/around_block.rb +2 -4
- data/lib/rubocop/cop/rspec/base.rb +0 -1
- data/lib/rubocop/cop/rspec/be_eq.rb +1 -1
- data/lib/rubocop/cop/rspec/be_eql.rb +1 -1
- data/lib/rubocop/cop/rspec/be_nil.rb +4 -0
- data/lib/rubocop/cop/rspec/change_by_zero.rb +4 -5
- data/lib/rubocop/cop/rspec/contain_exactly.rb +1 -0
- data/lib/rubocop/cop/rspec/context_wording.rb +15 -9
- data/lib/rubocop/cop/rspec/dialect.rb +13 -0
- data/lib/rubocop/cop/rspec/empty_example_group.rb +2 -0
- data/lib/rubocop/cop/rspec/empty_metadata.rb +1 -0
- data/lib/rubocop/cop/rspec/example_wording.rb +3 -5
- data/lib/rubocop/cop/rspec/excessive_docstring_spacing.rb +1 -1
- data/lib/rubocop/cop/rspec/expect_actual.rb +3 -3
- data/lib/rubocop/cop/rspec/expect_in_hook.rb +1 -1
- data/lib/rubocop/cop/rspec/expect_in_let.rb +42 -0
- data/lib/rubocop/cop/rspec/focus.rb +14 -16
- data/lib/rubocop/cop/rspec/implicit_expect.rb +3 -3
- data/lib/rubocop/cop/rspec/implicit_subject.rb +8 -0
- data/lib/rubocop/cop/rspec/indexed_let.rb +6 -3
- data/lib/rubocop/cop/rspec/leaky_constant_declaration.rb +1 -1
- data/lib/rubocop/cop/rspec/match_array.rb +1 -0
- data/lib/rubocop/cop/rspec/message_spies.rb +4 -0
- data/lib/rubocop/cop/rspec/metadata_style.rb +1 -6
- data/lib/rubocop/cop/rspec/missing_expectation_target_method.rb +54 -0
- data/lib/rubocop/cop/rspec/mixin/metadata.rb +5 -8
- data/lib/rubocop/cop/rspec/mixin/top_level_group.rb +7 -0
- data/lib/rubocop/cop/rspec/multiple_describes.rb +1 -1
- data/lib/rubocop/cop/rspec/multiple_expectations.rb +4 -4
- data/lib/rubocop/cop/rspec/multiple_memoized_helpers.rb +4 -5
- data/lib/rubocop/cop/rspec/named_subject.rb +5 -2
- data/lib/rubocop/cop/rspec/nested_groups.rb +2 -1
- data/lib/rubocop/cop/rspec/pending_without_reason.rb +0 -5
- data/lib/rubocop/cop/rspec/predicate_matcher.rb +25 -11
- data/lib/rubocop/cop/rspec/remove_const.rb +0 -1
- data/lib/rubocop/cop/rspec/repeated_subject_call.rb +1 -0
- data/lib/rubocop/cop/rspec/return_from_stub.rb +5 -4
- data/lib/rubocop/cop/rspec/scattered_setup.rb +7 -1
- data/lib/rubocop/cop/rspec/single_argument_message_chain.rb +3 -4
- data/lib/rubocop/cop/rspec/sort_metadata.rb +22 -8
- data/lib/rubocop/cop/rspec/stubbed_mock.rb +15 -10
- data/lib/rubocop/cop/rspec/subject_stub.rb +2 -2
- data/lib/rubocop/cop/rspec/unspecified_exception.rb +21 -14
- data/lib/rubocop/cop/rspec/verified_double_reference.rb +14 -53
- data/lib/rubocop/cop/rspec/void_expect.rb +6 -1
- data/lib/rubocop/cop/rspec_cops.rb +2 -25
- data/lib/rubocop/rspec/concept.rb +0 -1
- data/lib/rubocop/rspec/config_formatter.rb +4 -32
- data/lib/rubocop/rspec/cop/generator.rb +25 -0
- data/lib/rubocop/rspec/description_extractor.rb +2 -2
- data/lib/rubocop/rspec/hook.rb +1 -1
- data/lib/rubocop/rspec/language.rb +0 -1
- data/lib/rubocop/rspec/node.rb +1 -1
- data/lib/rubocop/rspec/plugin.rb +37 -0
- data/lib/rubocop/rspec/shared_contexts/default_rspec_language_config_context.rb +1 -1
- data/lib/rubocop/rspec/version.rb +1 -1
- data/lib/rubocop/rspec/wording.rb +2 -4
- data/lib/rubocop/rspec.rb +0 -7
- data/lib/rubocop-rspec.rb +2 -20
- metadata +18 -62
- data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +0 -39
- data/lib/rubocop/cop/rspec/capybara/feature_methods.rb +0 -104
- data/lib/rubocop/cop/rspec/capybara/match_style.rb +0 -38
- data/lib/rubocop/cop/rspec/capybara/negation_matcher.rb +0 -33
- data/lib/rubocop/cop/rspec/capybara/specific_actions.rb +0 -29
- data/lib/rubocop/cop/rspec/capybara/specific_finders.rb +0 -24
- data/lib/rubocop/cop/rspec/capybara/specific_matcher.rb +0 -35
- data/lib/rubocop/cop/rspec/capybara/visibility_matcher.rb +0 -36
- data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +0 -35
- data/lib/rubocop/cop/rspec/factory_bot/consistent_parentheses_style.rb +0 -50
- data/lib/rubocop/cop/rspec/factory_bot/create_list.rb +0 -40
- data/lib/rubocop/cop/rspec/factory_bot/factory_class_name.rb +0 -29
- data/lib/rubocop/cop/rspec/factory_bot/factory_name_style.rb +0 -33
- data/lib/rubocop/cop/rspec/factory_bot/syntax_methods.rb +0 -55
- data/lib/rubocop/cop/rspec/file_path.rb +0 -179
- data/lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb +0 -27
- data/lib/rubocop/cop/rspec/rails/have_http_status.rb +0 -35
- data/lib/rubocop/cop/rspec/rails/http_status.rb +0 -61
- data/lib/rubocop/cop/rspec/rails/inferred_spec_type.rb +0 -62
- data/lib/rubocop/cop/rspec/rails/minitest_assertions.rb +0 -39
- data/lib/rubocop/cop/rspec/rails/negation_be_valid.rb +0 -39
- data/lib/rubocop/cop/rspec/rails/travel_around.rb +0 -34
- data/lib/rubocop/rspec/inject.rb +0 -18
- data/lib/rubocop/rspec/language/node_pattern.rb +0 -48
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module RSpec
|
6
|
-
module Rails
|
7
|
-
# @!parse
|
8
|
-
# # Check if using Minitest-like matchers.
|
9
|
-
# #
|
10
|
-
# # Check the use of minitest-like matchers
|
11
|
-
# # starting with `assert_` or `refute_`.
|
12
|
-
# #
|
13
|
-
# # @example
|
14
|
-
# # # bad
|
15
|
-
# # assert_equal(a, b)
|
16
|
-
# # assert_equal a, b, "must be equal"
|
17
|
-
# # assert_not_includes a, b
|
18
|
-
# # refute_equal(a, b)
|
19
|
-
# # assert_nil a
|
20
|
-
# # refute_empty(b)
|
21
|
-
# # assert_true(a)
|
22
|
-
# # assert_false(a)
|
23
|
-
# #
|
24
|
-
# # # good
|
25
|
-
# # expect(b).to eq(a)
|
26
|
-
# # expect(b).to(eq(a), "must be equal")
|
27
|
-
# # expect(a).not_to include(b)
|
28
|
-
# # expect(b).not_to eq(a)
|
29
|
-
# # expect(a).to eq(nil)
|
30
|
-
# # expect(a).not_to be_empty
|
31
|
-
# # expect(a).to be(true)
|
32
|
-
# # expect(a).to be(false)
|
33
|
-
# #
|
34
|
-
# class MinitestAssertions < RuboCop::Cop::RSpec::Base; end
|
35
|
-
MinitestAssertions = ::RuboCop::Cop::RSpecRails::MinitestAssertions
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module RSpec
|
6
|
-
module Rails
|
7
|
-
# @!parse
|
8
|
-
# # Enforces use of `be_invalid` or `not_to` for negated be_valid.
|
9
|
-
# #
|
10
|
-
# # @safety
|
11
|
-
# # This cop is unsafe because it cannot guarantee that
|
12
|
-
# # the test target is an instance of `ActiveModel::Validations``.
|
13
|
-
# #
|
14
|
-
# # @example EnforcedStyle: not_to (default)
|
15
|
-
# # # bad
|
16
|
-
# # expect(foo).to be_invalid
|
17
|
-
# #
|
18
|
-
# # # good
|
19
|
-
# # expect(foo).not_to be_valid
|
20
|
-
# #
|
21
|
-
# # # good (with method chain)
|
22
|
-
# # expect(foo).to be_invalid.and be_odd
|
23
|
-
# #
|
24
|
-
# # @example EnforcedStyle: be_invalid
|
25
|
-
# # # bad
|
26
|
-
# # expect(foo).not_to be_valid
|
27
|
-
# #
|
28
|
-
# # # good
|
29
|
-
# # expect(foo).to be_invalid
|
30
|
-
# #
|
31
|
-
# # # good (with method chain)
|
32
|
-
# # expect(foo).to be_invalid.or be_even
|
33
|
-
# #
|
34
|
-
# class NegationBeValid < RuboCop::Cop::RSpec::Base; end
|
35
|
-
NegationBeValid = ::RuboCop::Cop::RSpecRails::NegationBeValid
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module RSpec
|
6
|
-
module Rails
|
7
|
-
# @!parse
|
8
|
-
# # Prefer to travel in `before` rather than `around`.
|
9
|
-
# #
|
10
|
-
# # @safety
|
11
|
-
# # This cop is unsafe because the automatic `travel_back` is only
|
12
|
-
# # run on test cases that are considered as Rails related.
|
13
|
-
# #
|
14
|
-
# # And also, this cop's autocorrection is unsafe because the order
|
15
|
-
# # of execution will change if other steps exist before traveling
|
16
|
-
# # in `around`.
|
17
|
-
# #
|
18
|
-
# # @example
|
19
|
-
# # # bad
|
20
|
-
# # around do |example|
|
21
|
-
# # freeze_time do
|
22
|
-
# # example.run
|
23
|
-
# # end
|
24
|
-
# # end
|
25
|
-
# #
|
26
|
-
# # # good
|
27
|
-
# # before { freeze_time }
|
28
|
-
# #
|
29
|
-
# class TravelAround < RuboCop::Cop::RSpec::Base; end
|
30
|
-
TravelAround = ::RuboCop::Cop::RSpecRails::TravelAround
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/rubocop/rspec/inject.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module RSpec
|
5
|
-
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
6
|
-
# bit of our configuration.
|
7
|
-
module Inject
|
8
|
-
def self.defaults!
|
9
|
-
path = CONFIG_DEFAULT.to_s
|
10
|
-
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
11
|
-
config = RuboCop::Config.new(hash, path)
|
12
|
-
puts "configuration from #{path}" if ConfigLoader.debug?
|
13
|
-
config = ConfigLoader.merge_with_default(config, path)
|
14
|
-
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module RSpec
|
5
|
-
module Language
|
6
|
-
# Helper methods to detect RSpec DSL used with send and block
|
7
|
-
# @deprecated Prefer using Node Pattern directly
|
8
|
-
# Use `'(block (send nil? #Example.all ...) ...)'` instead of
|
9
|
-
# `block_pattern('#Example.all')`
|
10
|
-
module NodePattern
|
11
|
-
# @deprecated Prefer using Node Pattern directly
|
12
|
-
def send_pattern(string)
|
13
|
-
deprecation_warning __method__
|
14
|
-
"(send #rspec? #{string} ...)"
|
15
|
-
end
|
16
|
-
|
17
|
-
# @deprecated Prefer using Node Pattern directly
|
18
|
-
def block_pattern(string)
|
19
|
-
deprecation_warning __method__
|
20
|
-
"(block #{send_pattern(string)} ...)"
|
21
|
-
end
|
22
|
-
|
23
|
-
# @deprecated Prefer using Node Pattern directly
|
24
|
-
def numblock_pattern(string)
|
25
|
-
deprecation_warning __method__
|
26
|
-
"(numblock #{send_pattern(string)} ...)"
|
27
|
-
end
|
28
|
-
|
29
|
-
# @deprecated Prefer using Node Pattern directly
|
30
|
-
def block_or_numblock_pattern(string)
|
31
|
-
deprecation_warning __method__
|
32
|
-
"{#{block_pattern(string)} #{numblock_pattern(string)}}"
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def deprecation_warning(method)
|
38
|
-
# Only warn in derived extensions' specs
|
39
|
-
return unless defined?(::RSpec)
|
40
|
-
|
41
|
-
Kernel.warn <<~MESSAGE, uplevel: 2
|
42
|
-
Usage of #{method} is deprecated. Use node pattern explicitly.
|
43
|
-
MESSAGE
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|