Merge pull request #11519 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-2.4.0

build(deps): bump rubocop-rspec from 2.3.0 to 2.4.0 in /Library/Homebrew
This commit is contained in:
Mike McQuaid 2021-06-10 12:25:36 +01:00 committed by GitHub
commit 33e71c99dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
117 changed files with 354 additions and 228 deletions

View File

@ -127,7 +127,7 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.3.0)
rubocop-rspec (2.4.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
rubocop-sorbet (0.6.2)

View File

@ -26803,6 +26803,7 @@ end
module RuboCop::AST::NodePattern::Sets
SET_BUILD_RECOMMENDED_TEST_OPTIONAL = ::T.let(nil, ::T.untyped)
SET_DEPENDS_ON_USES_FROM_MACOS = ::T.let(nil, ::T.untyped)
SET_EQL_EQ_BE = ::T.let(nil, ::T.untyped)
SET_INCLUDE_WITH_WITHOUT = ::T.let(nil, ::T.untyped)
SET_SYSTEM_SHELL_OUTPUT_PIPE_OUTPUT = ::T.let(nil, ::T.untyped)
SET_WITH_WITHOUT = ::T.let(nil, ::T.untyped)

View File

@ -17,7 +17,9 @@ describe PkgVersion do
specify "#==" do
expect(described_class.parse("1.0_0")).to be == described_class.parse("1.0")
expect(described_class.parse("1.0_1")).to be == described_class.parse("1.0_1")
version_to_compare = described_class.parse("1.0_1")
expect(version_to_compare == described_class.parse("1.0_1")).to be true
expect(version_to_compare == described_class.parse("1.0_2")).to be false
end
describe "#>" do

View File

@ -82,7 +82,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-1.16.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.11.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rails-2.10.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.3.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-2.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-sorbet-0.6.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.5.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"

View File

@ -351,6 +351,12 @@ RSpec/HooksBeforeExamples:
VersionAdded: '1.29'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
RSpec/IdenticalEqualityAssertion:
Description: Checks for equality assertions with identical expressions on both sides.
Enabled: pending
VersionAdded: '2.4'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IdenticalEqualityAssertion
RSpec/ImplicitBlockExpectation:
Description: Check that implicit block expectation syntax is not used.
Enabled: true
@ -753,6 +759,12 @@ RSpec/FactoryBot/FactoryClassName:
VersionChanged: '2.0'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName
RSpec/Rails/AvoidSetupHook:
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
Enabled: pending
VersionAdded: '2.4'
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
RSpec/Rails/HttpStatus:
Description: Enforces use of symbolic or numeric value to describe HTTP status.
Enabled: true

View File

@ -203,7 +203,7 @@ module RuboCop
[name]
elsif namespace.const_type?
[*const_name(namespace), name]
elsif namespace.lvar_type? || namespace.cbase_type?
elsif %i[lvar cbase send].include?(namespace.type)
[nil, name]
end
end

View File

@ -39,7 +39,7 @@ module RuboCop
# @!method expect_change_with_arguments(node)
def_node_matcher :expect_change_with_arguments, <<-PATTERN
(send nil? :change ({const send} nil? $_) (sym $_))
(send nil? :change $_ (sym $_))
PATTERN
# @!method expect_change_with_block(node)
@ -55,9 +55,9 @@ module RuboCop
return unless style == :block
expect_change_with_arguments(node) do |receiver, message|
msg = format(MSG_CALL, obj: receiver, attr: message)
msg = format(MSG_CALL, obj: receiver.source, attr: message)
add_offense(node, message: msg) do |corrector|
replacement = "change { #{receiver}.#{message} }"
replacement = "change { #{receiver.source}.#{message} }"
corrector.replace(node, replacement)
end
end

View File

@ -61,10 +61,10 @@ module RuboCop
MSG = 'Spec path should end with `%<suffix>s`.'
# @!method const_described(node)
def_node_matcher :const_described, <<~PATTERN
# @!method example_group(node)
def_node_matcher :example_group, <<~PATTERN
(block
$(send #rspec? _example_group $(const ...) $...) ...
$(send #rspec? _example_group $_ $...) ...
)
PATTERN
@ -74,17 +74,17 @@ module RuboCop
def on_top_level_example_group(node)
return unless top_level_groups.one?
const_described(node) do |send_node, described_class, arguments|
example_group(node) do |send_node, example_group, arguments|
next if routing_spec?(arguments)
ensure_correct_file_path(send_node, described_class, arguments)
ensure_correct_file_path(send_node, example_group, arguments)
end
end
private
def ensure_correct_file_path(send_node, described_class, arguments)
pattern = pattern_for(described_class, arguments.first)
def ensure_correct_file_path(send_node, example_group, arguments)
pattern = pattern_for(example_group, arguments.first)
return if filename_ends_with?(pattern)
# For the suffix shown in the offense message, modify the regular
@ -99,11 +99,13 @@ module RuboCop
args.any?(&method(:routing_metadata?))
end
def pattern_for(described_class, method_name)
return pattern_for_spec_suffix_only? if spec_suffix_only?
def pattern_for(example_group, method_name)
if spec_suffix_only? || !example_group.const_type?
return pattern_for_spec_suffix_only?
end
[
expected_path(described_class),
expected_path(example_group),
name_pattern(method_name),
'[^/]*_spec\.rb'
].join

View File

@ -0,0 +1,38 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
# Checks for equality assertions with identical expressions on both sides.
#
# @example
#
# # bad
# expect(foo.bar).to eq(foo.bar)
# expect(foo.bar).to eql(foo.bar)
#
# # good
# expect(foo.bar).to eq(2)
# expect(foo.bar).to eql(2)
#
class IdenticalEqualityAssertion < Base
MSG = 'Identical expressions on both sides of the equality ' \
'may indicate a flawed test.'
RESTRICT_ON_SEND = %i[to].freeze
# @!method equality_check?(node)
def_node_matcher :equality_check?, <<~PATTERN
(send (send nil? :expect $_) :to
{(send nil? {:eql :eq :be} $_)
(send (send nil? :be) :== $_)})
PATTERN
def on_send(node)
equality_check?(node) do |left, right|
add_offense(node) if left == right
end
end
end
end
end
end

View File

@ -7,7 +7,7 @@ module RuboCop
#
# This cop can be configured using the `EnforcedStyle` option
#
# @example `EnforcedStyle: single_line_only`
# @example `EnforcedStyle: single_line_only` (default)
# # bad
# it do
# is_expected.to be_truthy
@ -19,6 +19,22 @@ module RuboCop
# expect(subject).to be_truthy
# end
#
# @example `EnforcedStyle: single_statement_only`
# # bad
# it do
# foo = 1
# is_expected.to be_truthy
# end
#
# # good
# it do
# foo = 1
# expect(subject).to be_truthy
# end
# it do
# is_expected.to be_truthy
# end
#
# @example `EnforcedStyle: disallow`
# # bad
# it { is_expected.to be_truthy }

View File

@ -0,0 +1,44 @@
# frozen_string_literal: true
module RuboCop
module Cop
module RSpec
module Rails
# Checks that tests use RSpec `before` hook over Rails `setup` method.
#
# @example
#
# # bad
# setup do
# allow(foo).to receive(:bar)
# end
#
# # good
# before do
# allow(foo).to receive(:bar)
# end
#
class AvoidSetupHook < Base
extend AutoCorrector
MSG = 'Use `before` instead of `setup`.'
# @!method setup_call(node)
def_node_matcher :setup_call, <<-PATTERN
(block
$(send nil? :setup)
(args) _)
PATTERN
def on_block(node)
setup_call(node) do |setup|
add_offense(node) do |corrector|
corrector.replace setup, 'before'
end
end
end
end
end
end
end
end

Some files were not shown because too many files have changed in this diff Show More