1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #40089 from the-spectator/add_inspect_to_ordered_options

Implement #inspect for ActiveSupport::OrderedOptions
This commit is contained in:
Rafael França 2020-08-26 13:44:11 -04:00 committed by GitHub
commit 0e9cd658f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -62,6 +62,10 @@ module ActiveSupport
def extractable_options?
true
end
def inspect
"#<#{self.class.name} #{self}>"
end
end
# +InheritableOptions+ provides a constructor to build an +OrderedOptions+

View file

@ -115,4 +115,14 @@ class OrderedOptionsTest < ActiveSupport::TestCase
end
assert_raises(KeyError) { a.non_existing_key! }
end
def test_inspect
a = ActiveSupport::OrderedOptions.new
assert_equal "#<ActiveSupport::OrderedOptions {}>", a.inspect
a.foo = :bar
a[:baz] = :quz
assert_equal "#<ActiveSupport::OrderedOptions {:foo=>:bar, :baz=>:quz}>", a.inspect
end
end