lib/rubocop/cop/rspec/predicate_matcher.rb in rubocop-rspec-1.42.0 vs lib/rubocop/cop/rspec/predicate_matcher.rb in rubocop-rspec-1.43.0

- old
+ new

@@ -206,22 +206,24 @@ case matcher = matcher.to_s when 'be_a', 'be_an', 'be_a_kind_of', 'a_kind_of', 'be_kind_of' 'is_a?' when 'be_an_instance_of', 'be_instance_of', 'an_instance_of' 'instance_of?' - when 'include', 'respond_to' - matcher + '?' + when 'include' + 'include?' + when 'respond_to' + 'respond_to?' when /^have_(.+)/ "has_#{Regexp.last_match(1)}?" else - matcher[/^be_(.+)/, 1] + '?' + "#{matcher[/^be_(.+)/, 1]}?" end end # rubocop:enable Metrics/MethodLength def replacement_matcher(node) - case [cop_config['Strict'], node.method_name == :to] + case [cop_config['Strict'], node.method?(:to)] when [true, true] 'be(true)' when [true, false] 'be(false)' when [false, true] @@ -267,11 +269,11 @@ # # bad # expect(foo).to be_something # # # good - the above code is rewritten to it by this cop # expect(foo.something?).to be_truthy - class PredicateMatcher < Cop + class PredicateMatcher < Base extend AutoCorrector include ConfigurableEnforcedStyle include InflectedHelper include ExplicitHelper @@ -284,18 +286,9 @@ end end def on_block(node) check_explicit(node) if style == :explicit - end - - def autocorrect(node) - case style - when :inflected - autocorrect_inflected(node) - when :explicit - autocorrect_explicit(node) - end end private # returns args location with whitespace