Skip to content

Commit e3353e5

Browse files
authored
Merge pull request rails#44495 from Edouard-chin/ec-integration-test-inspect
Don't output the whole Rails::Railtie object when a NoMethodError is raised
2 parents ea9f010 + e60dd82 commit e3353e5

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

railties/lib/rails/railtie.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ def initialize # :nodoc:
247247
end
248248
end
249249

250+
def inspect # :nodoc:
251+
"#<#{self.class.name}>"
252+
end
253+
250254
def configure(&block) # :nodoc:
251255
instance_eval(&block)
252256
end

railties/test/railties/railtie_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,18 @@ class MyTie < Rails::Railtie
224224
Rails.env = original_env
225225
assert_equal(original_env, Rails.env)
226226
end
227+
228+
test "Railtie object isn't output when a NoMethodError is raised" do
229+
class Foo < Rails::Railtie
230+
config.foo = ActiveSupport::OrderedOptions.new
231+
config.foo.greetings = "hello"
232+
end
233+
234+
error = assert_raises(NoMethodError) do
235+
Foo.instance.abc
236+
end
237+
238+
assert_equal("undefined method `abc' for #<RailtiesTest::RailtieTest::Foo>", error.original_message)
239+
end
227240
end
228241
end

0 commit comments

Comments
 (0)