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?
|
def extractable_options?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
"#<#{self.class.name} #{self}>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# +InheritableOptions+ provides a constructor to build an +OrderedOptions+
|
# +InheritableOptions+ provides a constructor to build an +OrderedOptions+
|
||||||
|
|
|
@ -115,4 +115,14 @@ class OrderedOptionsTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
assert_raises(KeyError) { a.non_existing_key! }
|
assert_raises(KeyError) { a.non_existing_key! }
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue