aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/ordered_options_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-26 13:21:28 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-26 13:21:28 -0300
commitb1f6be9b5ea9eae4f6c5762852027d4808a037e2 (patch)
treef3782b6aa1531d89587720d19aca421f4a2ee580 /activesupport/test/ordered_options_test.rb
parent58ed699376f378f6d9b1a23484fcee4454ddaee5 (diff)
parente768c519fb6015e00961702a5165c6dab548a954 (diff)
downloadrails-b1f6be9b5ea9eae4f6c5762852027d4808a037e2.tar.gz
rails-b1f6be9b5ea9eae4f6c5762852027d4808a037e2.tar.bz2
rails-b1f6be9b5ea9eae4f6c5762852027d4808a037e2.zip
Merge pull request #20208 from gaurish/raise_on_missing_ordered_options
Add bang version to OrderedOptions
Diffstat (limited to 'activesupport/test/ordered_options_test.rb')
-rw-r--r--activesupport/test/ordered_options_test.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/ordered_options_test.rb b/activesupport/test/ordered_options_test.rb
index fdc745b23b..18767a3536 100644
--- a/activesupport/test/ordered_options_test.rb
+++ b/activesupport/test/ordered_options_test.rb
@@ -85,4 +85,19 @@ class OrderedOptionsTest < ActiveSupport::TestCase
assert_equal 42, a.method(:blah=).call(42)
assert_equal 42, a.method(:blah).call
end
+
+ def test_raises_with_bang
+ a = ActiveSupport::OrderedOptions.new
+ a[:foo] = :bar
+ assert a.respond_to?(:foo!)
+
+ assert_nothing_raised { a.foo! }
+ assert_equal a.foo, a.foo!
+
+ assert_raises(KeyError) do
+ a.foo = nil
+ a.foo!
+ end
+ assert_raises(KeyError) { a.non_existing_key! }
+ end
end