Skip to content

Commit

Permalink
Implement proper reset settings for adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
rwz committed Apr 27, 2014
1 parent ed19665 commit c5099ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion spec/gson_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

describe MultiJson::Adapters::Gson do
it_behaves_like 'an adapter', described_class
end
end
8 changes: 3 additions & 5 deletions spec/oj_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@

describe '.dump' do
describe '#dump_options' do
before{ MultiJson.use :oj }
before{ MultiJson.dump_options = MultiJson.adapter.dump_options = {} }
after{ MultiJson.dump_options = MultiJson.adapter.dump_options = {} }
around{ |example| with_default_options(&example) }

it 'ensures indent is a Fixnum' do
expect { MultiJson.dump(42, :indent => '')}.not_to raise_error
expect{ MultiJson.dump(42, :indent => '')}.not_to raise_error
end
end
end
end
end
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ def get_exception(exception_class = StandardError)
exception
end
end

def with_default_options
adapter = MultiJson.adapter
adapter.load_options = adapter.dump_options = MultiJson.load_options = MultiJson.dump_options = nil
yield
ensure
adapter.load_options = adapter.dump_options = MultiJson.load_options = MultiJson.dump_options = nil
end

0 comments on commit c5099ac

Please sign in to comment.