diff --git a/lib/rspec/support/differ.rb b/lib/rspec/support/differ.rb index d59890a15..a29b44492 100644 --- a/lib/rspec/support/differ.rb +++ b/lib/rspec/support/differ.rb @@ -47,8 +47,6 @@ def diff_as_string(actual, expected) finalize_output(output, hunks.last.diff(format_type).to_s) if hunks.last color_diff output - rescue Encoding::CompatibilityError - handle_encoding_errors end # rubocop:enable MethodLength @@ -197,17 +195,6 @@ def pick_encoding(source_a, source_b) def pick_encoding(_source_a, _source_b) end end - - def handle_encoding_errors - if @actual.source_encoding != @expected.source_encoding - "Could not produce a diff because the encoding of the actual string " \ - "(#{@actual.source_encoding}) differs from the encoding of the expected " \ - "string (#{@expected.source_encoding})" - else - "Could not produce a diff because of the encoding of the string " \ - "(#{@expected.source_encoding})" - end - end end # rubocop:enable ClassLength end diff --git a/spec/rspec/support/differ_spec.rb b/spec/rspec/support/differ_spec.rb index abd927a3c..240a8b6f9 100644 --- a/spec/rspec/support/differ_spec.rb +++ b/spec/rspec/support/differ_spec.rb @@ -68,17 +68,6 @@ module Support expect(differ.diff(actual, expected)).to eq("\n@@ -1,2 +1,2 @@\n-Tu avec carte {count} item has\n+Tu avec carté {count} itém has\n") expect(differ.diff(actual, expected).encoding).to eq(Encoding.default_external) end - - it 'handles any encoding error that occurs with a helpful error message' do - expect(RSpec::Support::HunkGenerator).to receive(:new). - and_raise(Encoding::CompatibilityError) - expected = "Tu avec carte {count} item has\n".encode('us-ascii') - actual = "Tu avec carté {count} itém has\n" - diff = differ.diff(actual, expected) - expect(diff).to match(/Could not produce a diff/) - expect(diff).to match(/actual string \(UTF-8\)/) - expect(diff).to match(/expected string \(US-ASCII\)/) - end end it "outputs unified diff message of two objects" do