lib/rubocop/cop/rspec/redundant_predicate_matcher.rb in rubocop-rspec-2.26.1 vs lib/rubocop/cop/rspec/redundant_predicate_matcher.rb in rubocop-rspec-2.27.0
- old
+ new
@@ -7,14 +7,16 @@
#
# @example
# # bad
# expect(foo).to be_exist(bar)
# expect(foo).not_to be_include(bar)
+ # expect(foo).to be_all(bar)
#
# # good
# expect(foo).to exist(bar)
# expect(foo).not_to include(bar)
+ # expect(foo).to all be(bar)
#
class RedundantPredicateMatcher < Base
extend AutoCorrector
MSG = 'Use `%<good>s` instead of `%<bad>s`.'
@@ -23,11 +25,11 @@
be_exist be_exists be_include be_match
be_respond_to be_start_with].freeze
def on_send(node)
return if node.parent.block_type? || node.arguments.empty?
- return unless replacable_arguments?(node)
+ return unless replaceable_arguments?(node)
method_name = node.method_name.to_s
replaced = replaced_method_name(method_name)
add_offense(node, message: message(method_name,
replaced)) do |corrector|
@@ -41,10 +43,10 @@
def message(bad_method, good_method)
format(MSG, bad: bad_method, good: good_method)
end
- def replacable_arguments?(node)
+ def replaceable_arguments?(node)
if node.method?(:be_all)
node.first_argument.send_type?
else
true
end