Merge pull request #6342 from Homebrew/dependabot/bundler/Library/Homebrew/rubocop-rspec-1.35.0
build: bump rubocop-rspec from 1.34.1 to 1.35.0 in /Library/Homebrew
This commit is contained in:
commit
42cf5f0160
@ -12,6 +12,8 @@ NewFormulaAudit:
|
|||||||
# Intentionally disabled as it doesn't fit with our code style.
|
# Intentionally disabled as it doesn't fit with our code style.
|
||||||
RSpec/AnyInstance:
|
RSpec/AnyInstance:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
RSpec/ImplicitBlockExpectation:
|
||||||
|
Enabled: false
|
||||||
|
|
||||||
# TODO: try to enable these (also requires fixing Homebrew/bundle)
|
# TODO: try to enable these (also requires fixing Homebrew/bundle)
|
||||||
RSpec/ContextWording:
|
RSpec/ContextWording:
|
||||||
|
|||||||
@ -89,7 +89,7 @@ GEM
|
|||||||
unicode-display_width (>= 1.4.0, < 1.7)
|
unicode-display_width (>= 1.4.0, < 1.7)
|
||||||
rubocop-performance (1.4.1)
|
rubocop-performance (1.4.1)
|
||||||
rubocop (>= 0.71.0)
|
rubocop (>= 0.71.0)
|
||||||
rubocop-rspec (1.34.1)
|
rubocop-rspec (1.35.0)
|
||||||
rubocop (>= 0.60.0)
|
rubocop (>= 0.60.0)
|
||||||
ruby-macho (2.2.0)
|
ruby-macho (2.2.0)
|
||||||
ruby-progressbar (1.10.1)
|
ruby-progressbar (1.10.1)
|
||||||
|
|||||||
@ -61,8 +61,8 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-retry-0.6.1/lib
|
|||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rspec-wait-0.0.9/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-progressbar-1.10.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.6.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/unicode-display_width-1.6.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.73.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-0.74.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.4.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-performance-1.4.1/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.34.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/rubocop-rspec-1.35.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ruby-macho-2.2.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-cobertura-1.3.1/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-cobertura-1.3.1/lib"
|
||||||
|
|||||||
@ -197,6 +197,11 @@ RSpec/HooksBeforeExamples:
|
|||||||
Description: Checks for before/around/after hooks that come after an example.
|
Description: Checks for before/around/after hooks that come after an example.
|
||||||
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
|
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HooksBeforeExamples
|
||||||
|
|
||||||
|
RSpec/ImplicitBlockExpectation:
|
||||||
|
Description: Check that implicit block expectation syntax is not used.
|
||||||
|
Enabled: true
|
||||||
|
StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ImplicitBlockExpectation
|
||||||
|
|
||||||
RSpec/ImplicitExpect:
|
RSpec/ImplicitExpect:
|
||||||
Description: Check that a consistent implicit expectation style is used.
|
Description: Check that a consistent implicit expectation style is used.
|
||||||
Enabled: true
|
Enabled: true
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module RuboCop
|
||||||
|
module Cop
|
||||||
|
module RSpec
|
||||||
|
# Check that implicit block expectation syntax is not used.
|
||||||
|
#
|
||||||
|
# Prefer using explicit block expectations.
|
||||||
|
#
|
||||||
|
# @example
|
||||||
|
# # bad
|
||||||
|
# subject { -> { do_something } }
|
||||||
|
# it { is_expected.to change(something).to(new_value) }
|
||||||
|
#
|
||||||
|
# # good
|
||||||
|
# it 'changes something to a new value' do
|
||||||
|
# expect { do_something }.to change(something).to(new_value)
|
||||||
|
# end
|
||||||
|
class ImplicitBlockExpectation < Cop
|
||||||
|
MSG = 'Avoid implicit block expectations.'
|
||||||
|
|
||||||
|
def_node_matcher :lambda?, <<-PATTERN
|
||||||
|
{
|
||||||
|
(send (const nil? :Proc) :new)
|
||||||
|
(send nil? :proc)
|
||||||
|
(send nil? :lambda)
|
||||||
|
}
|
||||||
|
PATTERN
|
||||||
|
|
||||||
|
def_node_matcher :lambda_subject?, '(block #lambda? ...)'
|
||||||
|
|
||||||
|
def_node_matcher :implicit_expect, <<-PATTERN
|
||||||
|
$(send nil? {:is_expected :should :should_not} ...)
|
||||||
|
PATTERN
|
||||||
|
|
||||||
|
def on_send(node)
|
||||||
|
implicit_expect(node) do |implicit_expect|
|
||||||
|
subject = nearest_subject(implicit_expect)
|
||||||
|
add_offense(implicit_expect) if lambda_subject?(subject&.body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def nearest_subject(node)
|
||||||
|
node
|
||||||
|
.each_ancestor(:block)
|
||||||
|
.lazy
|
||||||
|
.select { |block_node| multi_statement_example_group?(block_node) }
|
||||||
|
.map { |block_node| find_subject(block_node) }
|
||||||
|
.find(&:itself)
|
||||||
|
end
|
||||||
|
|
||||||
|
def multi_statement_example_group?(node)
|
||||||
|
example_group_with_body?(node) && node.body.begin_type?
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_subject(block_node)
|
||||||
|
block_node.body.child_nodes.find { |send_node| subject?(send_node) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -41,6 +41,7 @@ require_relative 'rspec/file_path'
|
|||||||
require_relative 'rspec/focus'
|
require_relative 'rspec/focus'
|
||||||
require_relative 'rspec/hook_argument'
|
require_relative 'rspec/hook_argument'
|
||||||
require_relative 'rspec/hooks_before_examples'
|
require_relative 'rspec/hooks_before_examples'
|
||||||
|
require_relative 'rspec/implicit_block_expectation'
|
||||||
require_relative 'rspec/implicit_expect'
|
require_relative 'rspec/implicit_expect'
|
||||||
require_relative 'rspec/implicit_subject'
|
require_relative 'rspec/implicit_subject'
|
||||||
require_relative 'rspec/instance_spy'
|
require_relative 'rspec/instance_spy'
|
||||||
@ -4,7 +4,7 @@ module RuboCop
|
|||||||
module RSpec
|
module RSpec
|
||||||
# Version information for the RSpec RuboCop plugin.
|
# Version information for the RSpec RuboCop plugin.
|
||||||
module Version
|
module Version
|
||||||
STRING = '1.34.1'
|
STRING = '1.35.0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user