Skip to content

Commit db767c3

Browse files
committed
Fix CI failure caused by error_highlight gem
Since ruby/ruby#4586, error.message includes the line of code that raised. https://bugs.ruby-lang.org/issues/17930
1 parent 8c03c8f commit db767c3

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

activerecord/test/cases/attribute_methods_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def topic.approved; false; end
918918
}
919919
assert_instance_of Topic, error.record
920920
assert_equal "hello", error.attribute
921-
assert_equal "unknown attribute 'hello' for Topic.", error.message
921+
assert_match "unknown attribute 'hello' for Topic.", error.message
922922
end
923923

924924
test "method overrides in multi-level subclasses" do

activerecord/test/cases/inheritance_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_compute_type_nonexistent_constant
6262
e = assert_raises NameError do
6363
Company.send :compute_type, "NonexistentModel"
6464
end
65-
assert_equal "uninitialized constant Company::NonexistentModel", e.message
65+
assert_match "uninitialized constant Company::NonexistentModel", e.message
6666
assert_equal "Company::NonexistentModel", e.name
6767
end
6868

activerecord/test/cases/nested_attributes_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_should_raise_an_UnknownAttributeError_for_non_existing_nested_attribute
6767
exception = assert_raise ActiveModel::UnknownAttributeError do
6868
Pirate.new(ship_attributes: { sail: true })
6969
end
70-
assert_equal "unknown attribute 'sail' for Ship.", exception.message
70+
assert_match "unknown attribute 'sail' for Ship.", exception.message
7171
end
7272

7373
def test_should_disable_allow_destroy_by_default
@@ -606,7 +606,7 @@ def test_should_raise_an_UnknownAttributeError_for_non_existing_nested_attribute
606606
exception = assert_raise ActiveModel::UnknownAttributeError do
607607
@pirate.parrots_attributes = [{ peg_leg: true }]
608608
end
609-
assert_equal "unknown attribute 'peg_leg' for Parrot.", exception.message
609+
assert_match "unknown attribute 'peg_leg' for Parrot.", exception.message
610610
end
611611

612612
def test_should_save_only_one_association_on_create

activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,28 +100,28 @@ def test_should_raise_name_error_if_attribute_name_is_invalid
100100
thread_cattr_reader "1nvalid"
101101
end
102102
end
103-
assert_equal "invalid attribute name: 1nvalid", exception.message
103+
assert_match "invalid attribute name: 1nvalid", exception.message
104104

105105
exception = assert_raises NameError do
106106
Class.new do
107107
thread_cattr_writer "1nvalid"
108108
end
109109
end
110-
assert_equal "invalid attribute name: 1nvalid", exception.message
110+
assert_match "invalid attribute name: 1nvalid", exception.message
111111

112112
exception = assert_raises NameError do
113113
Class.new do
114114
thread_mattr_reader "1valid_part"
115115
end
116116
end
117-
assert_equal "invalid attribute name: 1valid_part", exception.message
117+
assert_match "invalid attribute name: 1valid_part", exception.message
118118

119119
exception = assert_raises NameError do
120120
Class.new do
121121
thread_mattr_writer "2valid_part"
122122
end
123123
end
124-
assert_equal "invalid attribute name: 2valid_part", exception.message
124+
assert_match "invalid attribute name: 2valid_part", exception.message
125125
end
126126

127127
def test_should_return_same_value_by_class_or_instance_accessor

activesupport/test/core_ext/module/attribute_accessor_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,28 @@ def test_should_raise_name_error_if_attribute_name_is_invalid
8585
cattr_reader "1nvalid"
8686
end
8787
end
88-
assert_equal "invalid attribute name: 1nvalid", exception.message
88+
assert_match "invalid attribute name: 1nvalid", exception.message
8989

9090
exception = assert_raises NameError do
9191
Class.new do
9292
cattr_writer "1nvalid"
9393
end
9494
end
95-
assert_equal "invalid attribute name: 1nvalid", exception.message
95+
assert_match "invalid attribute name: 1nvalid", exception.message
9696

9797
exception = assert_raises NameError do
9898
Class.new do
9999
mattr_reader "valid_part\ninvalid_part"
100100
end
101101
end
102-
assert_equal "invalid attribute name: valid_part\ninvalid_part", exception.message
102+
assert_match "invalid attribute name: valid_part\ninvalid_part", exception.message
103103

104104
exception = assert_raises NameError do
105105
Class.new do
106106
mattr_writer "valid_part\ninvalid_part"
107107
end
108108
end
109-
assert_equal "invalid attribute name: valid_part\ninvalid_part", exception.message
109+
assert_match "invalid attribute name: valid_part\ninvalid_part", exception.message
110110
end
111111

112112
def test_should_use_default_value_if_block_passed

activesupport/test/core_ext/time_with_zone_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ def test_no_method_error_has_proper_context
10781078
e = assert_raises(NoMethodError) {
10791079
@twz.this_method_does_not_exist
10801080
}
1081-
assert_equal "undefined method `this_method_does_not_exist' for Fri, 31 Dec 1999 19:00:00.000000000 EST -05:00:ActiveSupport::TimeWithZone", e.message
1081+
assert_match "undefined method `this_method_does_not_exist' for Fri, 31 Dec 1999 19:00:00.000000000 EST -05:00:ActiveSupport::TimeWithZone", e.message
10821082
assert_no_match "rescue", e.backtrace.first
10831083
end
10841084
end

railties/test/application/loading_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class Post
4444
boot_app
4545

4646
e = assert_raise(NameError) { User }
47-
assert_equal "uninitialized constant #{self.class}::User", e.message
47+
assert_match "uninitialized constant #{self.class}::User", e.message
4848

4949
e = assert_raise(NameError) { Post }
50-
assert_equal "uninitialized constant Post::NON_EXISTING_CONSTANT", e.message
50+
assert_match "uninitialized constant Post::NON_EXISTING_CONSTANT", e.message
5151
end
5252

5353
test "concerns in app are autoloaded" do

0 commit comments

Comments
 (0)