summaryrefslogtreecommitdiff
blob: 2e031e0c01a49d903272a97688425194c4a00e1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
A small part of 

commit d83002691a34a32b6d6d181817af7f8e68524638
Author: Erik Michaels-Ober <sferik@gmail.com>
Date:   Sat May 14 09:26:31 2011 -0700

    Cleanup

diff --git a/spec/multi_json_spec.rb b/spec/multi_json_spec.rb
index 9be78f4..55238c9 100644
--- b/spec/multi_json_spec.rb
+++ a/spec/multi_json_spec.rb
@@ -1,9 +1,9 @@
-require 'helper'
+require 'spec_helper'
 require 'stringio'
-
+          
 class MockDecoder
   def self.decode(string, options = {})
-    {'abc' => 'def'}
+    { 'abc' => 'def' }
   end
 
   def self.encode(string)
@@ -26,10 +26,16 @@
         end
       end
     end
-
+    
     it 'defaults to the best available gem' do
-      require 'yajl'
-      MultiJson.engine.name.should == 'MultiJson::Engines::Yajl'
+      # the yajl-ruby gem does not work on jruby, so the best engine is the JsonGem engine
+      if jruby?
+        require 'json'
+        MultiJson.engine.name.should == 'MultiJson::Engines::JsonGem'
+      else
+        require 'yajl'
+        MultiJson.engine.name.should == 'MultiJson::Engines::Yajl'
+      end
     end
 
     it 'is settable via a symbol' do
@@ -89,7 +95,7 @@
           encoded_json = MultiJson.encode(:a => 1, :b => {:c => 2})
           MultiJson.decode(encoded_json).should == { "a" => 1, "b" => { "c" => 2 } }
         end
-
+        
         it "properly decodes valid JSON in StringIOs" do
           json = StringIO.new('{"abc":"def"}')
           MultiJson.decode(json).should == { 'abc' => 'def' }
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
deleted file mode 100644
index a9b66e6..0000000
--- /dev/null
+++ a/spec/spec_helper.rb
@@ -0,0 +1,15 @@
+begin
+  require 'bundler'
+rescue LoadError
+  puts "although not required, it's recommended that you use bundler during development"
+end
+
+require 'rspec'
+require 'rspec/autorun'
+
+$VERBOSE = true
+require 'multi_json'
+
+def jruby?
+  defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
+end