|
9 | 9 | context 'when no other json implementations are available' do |
10 | 10 | before do |
11 | 11 | @old_map = MultiJson::REQUIREMENT_MAP |
| 12 | + @old_oj = Object.const_get :Oj if Object.const_defined?(:Oj) |
12 | 13 | @old_yajl = Object.const_get :Yajl if Object.const_defined?(:Yajl) |
13 | 14 | @old_json = Object.const_get :JSON if Object.const_defined?(:JSON) |
14 | 15 | MultiJson::REQUIREMENT_MAP.each_with_index do |(library, engine), index| |
15 | 16 | MultiJson::REQUIREMENT_MAP[index] = ["foo/#{library}", engine] |
16 | 17 | end |
| 18 | + Object.send :remove_const, :Oj if @old_oj |
17 | 19 | Object.send :remove_const, :Yajl if @old_yajl |
18 | 20 | Object.send :remove_const, :JSON if @old_json |
19 | 21 | end |
|
22 | 24 | @old_map.each_with_index do |(library, engine), index| |
23 | 25 | MultiJson::REQUIREMENT_MAP[index] = [library, engine] |
24 | 26 | end |
| 27 | + Object.const_set :Oj, @old_oj if @old_oj |
25 | 28 | Object.const_set :Yajl, @old_yajl if @old_yajl |
26 | 29 | Object.const_set :JSON, @old_json if @old_json |
27 | 30 | end |
|
38 | 41 |
|
39 | 42 | it 'defaults to the best available gem' do |
40 | 43 | unless jruby? |
41 | | - require 'yajl' |
42 | | - MultiJson.engine.name.should == 'MultiJson::Engines::Yajl' |
| 44 | + require 'oj' |
| 45 | + MultiJson.engine.name.should == 'MultiJson::Engines::Oj' |
43 | 46 | else |
44 | 47 | require 'json' |
45 | 48 | MultiJson.engine.name.should == 'MultiJson::Engines::JsonGem' |
|
57 | 60 | end |
58 | 61 | end |
59 | 62 |
|
60 | | - %w(json_gem json_pure ok_json yajl nsjsonserialization).each do |engine| |
61 | | - if yajl_on_travis(engine) |
62 | | - puts "Yajl with JRuby is not tested on Travis as C-exts are turned off due to there experimental nature" |
63 | | - next |
64 | | - end |
| 63 | + %w(json_gem json_pure nsjsonserialization oj ok_json yajl).each do |engine| |
65 | 64 | if nsjsonserialization_on_other_than_macruby(engine) |
66 | 65 | puts "NSJSONSerialization is exclusively available for MacRuby only." |
67 | 66 | next |
|
0 commit comments