@@ -141,6 +141,47 @@ class ConfigTest < Test::Unit::TestCase
141141 assert_same Config . global , Config . new ( Config . global ) . parent
142142 end
143143
144+ test "#freeze" do
145+ config = Config . new ( open_timeout : 1 )
146+ config . freeze
147+ assert_raise FrozenError do
148+ config . open_timeout = 2
149+ end
150+ assert_same 1 , config . open_timeout
151+ end
152+
153+ test "#dup" do
154+ original = Config . new ( open_timeout : 1 )
155+ copy = original . dup
156+ refute_same original , copy
157+ copy . open_timeout = 2
158+ assert_equal 1 , original . open_timeout
159+ assert_equal 2 , copy . open_timeout
160+
161+ original . freeze
162+ copy = original . dup
163+ refute copy . frozen?
164+ copy . open_timeout = 2
165+ assert_equal 2 , copy . open_timeout
166+ end
167+
168+ test "#clone" do
169+ original = Config . new ( open_timeout : 1 )
170+ copy = original . clone
171+ refute_same original , copy
172+ copy . open_timeout = 2
173+ assert_equal 1 , original . open_timeout
174+ assert_equal 2 , copy . open_timeout
175+
176+ original . freeze
177+ copy = original . clone
178+ assert copy . frozen?
179+ assert_raise FrozenError do
180+ copy . open_timeout = 2
181+ end
182+ assert_equal 1 , copy . open_timeout
183+ end
184+
144185 test "#inherited? and #reset(attr)" do
145186 base = Config . new debug : false , open_timeout : 99 , idle_response_timeout : 15
146187 child = base . new debug : true , open_timeout : 15 , idle_response_timeout : 10
0 commit comments