Permalink
Browse files

Fix order-dependency bug in specs

  • Loading branch information...
sferik committed Jan 15, 2012
1 parent 20b4eb6 commit 01f6bd41ea295957782eb46b63665041b8d1f8fa
Showing with 7 additions and 2 deletions.
  1. +2 −0 lib/multi_json.rb
  2. +5 −2 spec/multi_json_spec.rb
View
@@ -60,6 +60,8 @@ def engine=(new_engine)
when String, Symbol
require "multi_json/engines/#{new_engine}"
@engine = MultiJson::Engines.const_get("#{new_engine.to_s.split('_').map{|s| s.capitalize}.join('')}")
+ when NilClass
+ @engine = nil
when Class
@engine = new_engine
else
View
@@ -3,8 +3,11 @@
describe "MultiJson" do
context 'engines' do
+ before do
+ MultiJson.engine = nil
+ end
context 'when no other json implementations are available' do
- before(:each) do
+ before do
@old_map = MultiJson::REQUIREMENT_MAP
@old_yajl = Object.const_get :Yajl if Object.const_defined?(:Yajl)
@old_json = Object.const_get :JSON if Object.const_defined?(:JSON)
@@ -15,7 +18,7 @@
Object.send :remove_const, :JSON if @old_json
end
- after(:each) do
+ after do
@old_map.each_with_index do |(library, engine), index|
MultiJson::REQUIREMENT_MAP[index] = [library, engine]
end

0 comments on commit 01f6bd4

Please sign in to comment.