From e768c519fb6015e00961702a5165c6dab548a954 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sun, 17 May 2015 16:21:34 +0530 Subject: Add bang version to OrderedOptions By: Aditya Sanghi(@asanghi) Gaurish Sharma(gaurish) --- activesupport/test/ordered_options_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activesupport/test/ordered_options_test.rb') 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 -- cgit v1.2.3