Permalink
Browse files

MultiJson does not modify arguments

Related to #92
  • Loading branch information...
rwz committed Feb 21, 2013
1 parent aebe316 commit 58525b01c4c2f6635ba2ac13d6fd987b79f3962f
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/multi_json.rb
  2. +6 −0 spec/adapter_shared_example.rb
View
@@ -119,7 +119,7 @@ def load(string, options={})
alias :decode :load
def current_adapter(options={})
- if new_adapter = options.delete(:adapter)
+ if new_adapter = options[:adapter]
load_adapter(new_adapter)
else
adapter
@@ -12,6 +12,12 @@
it_behaves_like 'has options', lambda{ MultiJson.adapter }
+ it 'does not modify argument hashes' do
+ options = { :symbolize_keys => true, :pretty => false, :adapter => :json_gem }
+ expect{MultiJson.load('{}', options)}.to_not change{options}
+ expect{MultiJson.dump([42], options)}.to_not change{options}
+ end
+
describe '.dump' do
describe '#dump_options' do
before{ MultiJson.dump_options = MultiJson.adapter.dump_options = {} }

0 comments on commit 58525b0

Please sign in to comment.