lib/rubocop/cop/rspec/predicate_matcher.rb in rubocop-rspec-1.23.0 vs lib/rubocop/cop/rspec/predicate_matcher.rb in rubocop-rspec-1.24.0
- old
+ new
@@ -103,21 +103,21 @@
corrector.replace(matcher.loc.expression,
to_predicate_matcher(name) + args + block)
end
- def true?(to, matcher)
+ def true?(to_symbol, matcher)
_recv, name, arg = *matcher
result = case name
when :be, :eq
arg.true_type?
when :be_truthy, :a_truthy_value
true
when :be_falsey, :be_falsy, :a_falsey_value, :a_falsy_value
false
end
- to == :to ? result : !result
+ to_symbol == :to ? result : !result
end
end
# A helper for `explicit` style
# rubocop:disable Metrics/ModuleLength
@@ -197,21 +197,21 @@
end
end
def autocorrect_explicit_block(node)
predicate_matcher_block?(node) do |actual, matcher|
- to, = *node
- corrector_explicit(to, actual, matcher, to)
+ to_node, = *node
+ corrector_explicit(to_node, actual, matcher, to_node)
end
end
- def corrector_explicit(to, actual, matcher, block_child)
+ def corrector_explicit(to_node, actual, matcher, block_child)
lambda do |corrector|
- replacement_matcher = replacement_matcher(to)
+ replacement_matcher = replacement_matcher(to_node)
corrector.replace(matcher.loc.expression, replacement_matcher)
move_predicate(corrector, actual, matcher, block_child)
- corrector.replace(to.loc.selector, 'to')
+ corrector.replace(to_node.loc.selector, 'to')
end
end
def move_predicate(corrector, actual, matcher, block_child)
predicate = to_predicate_method(matcher.method_name)
@@ -295,9 +295,10 @@
# expect(foo.something?).to be_truthy
class PredicateMatcher < Cop
include ConfigurableEnforcedStyle
include InflectedHelper
include ExplicitHelper
+ include RangeHelp
def on_send(node)
case style
when :inflected
check_inflected(node)