Skip to content

Commit

Permalink
test default_engine by invalidating the other requires
Browse files Browse the repository at this point in the history
  • Loading branch information
joshk committed May 4, 2011
1 parent 679f6ed commit 539d36c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/multi_json_spec.rb
Expand Up @@ -13,6 +13,20 @@ def self.encode(string)

describe "MultiJson" do
context 'engines' do
it 'defaults to ok_json if no other json implementions are available' do
old_map = MultiJson::REQUIREMENT_MAP
begin
MultiJson::REQUIREMENT_MAP.each_with_index do |(library, engine), index|
MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", engine]
end
MultiJson.default_engine.should == :ok_json
ensure
old_map.each_with_index do |(library, engine), index|
MultiJson::REQUIREMENT_MAP[index] = [library, engine]
end
end
end

it 'defaults to the best available gem' do
# the yajl-ruby gem does not work on jruby, so the best engine is the JsonGem engine
if jruby?
Expand Down

0 comments on commit 539d36c

Please sign in to comment.