diff options
author | Gaurish Sharma <contact@gaurishsharma.com> | 2015-05-17 16:21:34 +0530 |
---|---|---|
committer | Gaurish Sharma <contact@gaurishsharma.com> | 2015-05-23 14:25:06 +0530 |
commit | e768c519fb6015e00961702a5165c6dab548a954 (patch) | |
tree | 00b4f408a6dd91c28f74efad7c64bc4f74bd0e07 /activesupport/test/ordered_options_test.rb | |
parent | 42e66fac38b54dd53d062fb5d3376218ed2ffdae (diff) | |
download | rails-e768c519fb6015e00961702a5165c6dab548a954.tar.gz rails-e768c519fb6015e00961702a5165c6dab548a954.tar.bz2 rails-e768c519fb6015e00961702a5165c6dab548a954.zip |
Add bang version to OrderedOptions
By:
Aditya Sanghi(@asanghi)
Gaurish Sharma(gaurish)
Diffstat (limited to 'activesupport/test/ordered_options_test.rb')
-rw-r--r-- | activesupport/test/ordered_options_test.rb | 15 |
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..bffefb6ad9 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 |