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:
commit
0e9cd658f9
2 changed files with 14 additions and 0 deletions
|
@ -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+
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue