Skip to content

ArgumentError#message changes since 0.5.0 #28

@yahonda

Description

@yahonda

Rails CI is getting failures since error_highlight 0.5.0. Refer to https://buildkite.com/rails/rails/builds/90833#0184571b-307d-4e94-8a2d-3c8a2669a12c/1052-1078

It is likely because error_highlight 0.5.0 takes care of ArgumentError via defcaf1

I expect error_highlight does not change the original message.

Steps to reproduce

  • create foo.rb file
require 'minitest/autorun'
require 'error_highlight'

def foo(*args)
  raise ArgumentError, 'You have to supply some args' if args.empty?
  args
end

class BugTest < Minitest::Test
  def test_foo
    error = assert_raises(ArgumentError) do
      foo()
    end
    assert_equal 'You have to supply some args', error.message
  end
end

Expected behavior

  • foo.rb works without failures with error_highlight 0.4.0
$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
$ gem install error_highlight -v 0.4.0
Fetching error_highlight-0.4.0.gem
Successfully installed error_highlight-0.4.0
Parsing documentation for error_highlight-0.4.0
Installing ri documentation for error_highlight-0.4.0
Done installing documentation for error_highlight after 0 seconds
1 gem installed
$ ruby foo.rb
Run options: --seed 46613

# Running:

.

Finished in 0.005816s, 171.9293 runs/s, 343.8587 assertions/s.
1 runs, 2 assertions, 0 failures, 0 errors, 0 skips
$

Actual behavior

  • foo.rb works without failures with error_highlight 0.4.0
$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
$ gem install error_highlight -v 0.5.0
Fetching error_highlight-0.5.0.gem
Successfully installed error_highlight-0.5.0
Parsing documentation for error_highlight-0.5.0
Installing ri documentation for error_highlight-0.5.0
Done installing documentation for error_highlight after 0 seconds
1 gem installed
yahonda@myryzen:~$ ruby foo.rb
Run options: --seed 48895

# Running:

F

Failure:
BugTest#test_foo [foo.rb:14]:
--- expected
+++ actual
@@ -1 +1,4 @@
-"You have to supply some args"
+"You have to supply some args
+
+  raise ArgumentError, 'You have to supply some args' if args.empty?
+        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"



rails test foo.rb:10



Finished in 0.008049s, 124.2380 runs/s, 248.4761 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions