lib/rubocop/cop/rspec/expect_actual.rb in rubocop-rspec-1.41.0 vs lib/rubocop/cop/rspec/expect_actual.rb in rubocop-rspec-1.42.0

- old
+ new

@@ -15,10 +15,12 @@ # expect(price).to eq(5) # expect(pattern).to eq(/foo/) # expect(name).to eq("John") # class ExpectActual < Cop + extend AutoCorrector + MSG = 'Provide the actual you are testing to `expect(...)`.' SIMPLE_LITERALS = %i[ true false @@ -53,20 +55,15 @@ } ) PATTERN def on_send(node) - expect_literal(node) do |argument| - add_offense(node, location: argument.source_range) - end - end + expect_literal(node) do |actual, matcher, expected| + add_offense(actual.source_range) do |corrector| + next unless SUPPORTED_MATCHERS.include?(matcher) - def autocorrect(node) - actual, matcher, expected = expect_literal(node) - lambda do |corrector| - return unless SUPPORTED_MATCHERS.include?(matcher) - - swap(corrector, actual, expected) + swap(corrector, actual, expected) + end end end private