Permalink
Browse files

Don't install Yajl on JRuby

  • Loading branch information...
1 parent 868be36 commit cc6325e3e712482fbe548d0b813f8c39fe4f36d4 @sferik sferik committed Mar 16, 2012
Showing with 21 additions and 21 deletions.
  1. +1 −1 Gemfile
  2. +4 −4 spec/helper.rb
  3. +16 −16 spec/multi_json_spec.rb
View
@@ -2,6 +2,6 @@ source 'https://rubygems.org'
gem 'json', '~> 1.4', :require => nil
gem 'oj', '~> 1.0', :require => nil, :platforms => [:ruby, :mswin, :mingw]
-gem 'yajl-ruby', '~> 1.0', :require => nil
+gem 'yajl-ruby', '~> 1.0', :require => nil, :platforms => [:ruby, :mswin, :mingw]
gemspec
View
@@ -1,3 +1,7 @@
+def jruby?
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
+end
+
def macruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
end
@@ -24,7 +28,3 @@ def to_json(options = {})
"\"2005-02-01T15:15:10Z\""
end
end
-
-def jruby?
- defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
-end
View
@@ -1,7 +1,7 @@
require 'helper'
require 'stringio'
-describe "MultiJson" do
+describe 'MultiJson' do
context 'engines' do
before do
MultiJson.engine = nil
@@ -62,7 +62,7 @@
%w(json_gem json_pure nsjsonserialization oj ok_json yajl).each do |engine|
next if !macruby? && engine == 'nsjsonserialization'
- next if jruby? && engine == 'oj'
+ next if jruby? && (engine == 'oj' || engine == 'yajl')
context engine do
before do
@@ -76,8 +76,8 @@
describe '.encode' do
it 'writes decodable JSON' do
[
- { 'abc' => 'def' },
- [1, 2, 3, "4"]
+ {'abc' => 'def'},
+ [1, 2, 3, "4"],
].each do |example|
MultiJson.decode(MultiJson.encode(example)).should == example
end
@@ -86,16 +86,16 @@
it 'encodes symbol keys as strings' do
[
[
- { :foo => { :bar => 'baz' } },
- { 'foo' => { 'bar' => 'baz' } }
+ {:foo => {:bar => 'baz'}},
+ {'foo' => {'bar' => 'baz'}},
],
[
- [ { :foo => { :bar => 'baz' } } ],
- [ { 'foo' => { 'bar' => 'baz' } } ],
+ [{:foo => {:bar => 'baz'}}],
+ [{'foo' => {'bar' => 'baz'}}],
],
[
- { :foo => [ { :bar => 'baz' } ] },
- { 'foo' => [ { 'bar' => 'baz' } ] },
+ {:foo => [{:bar => 'baz'}]},
+ {'foo' => [{'bar' => 'baz'}]},
]
].each do |example, expected|
encoded_json = MultiJson.encode(example)
@@ -130,7 +130,7 @@
describe '.decode' do
it 'properly decodes valid JSON' do
- MultiJson.decode('{"abc":"def"}').should == { 'abc' => 'def' }
+ MultiJson.decode('{"abc":"def"}').should == {'abc' => 'def'}
end
it 'raises MultiJson::DecodeError on invalid JSON' do
@@ -150,27 +150,27 @@
it 'stringifys symbol keys when encoding' do
encoded_json = MultiJson.encode(:a => 1, :b => {:c => 2})
- MultiJson.decode(encoded_json).should == { "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' }
+ MultiJson.decode(json).should == {'abc' => 'def'}
end
it 'allows for symbolization of keys' do
[
[
'{"abc":{"def":"hgi"}}',
- { :abc => { :def => 'hgi' } }
+ {:abc => {:def => 'hgi'}},
],
[
'[{"abc":{"def":"hgi"}}]',
- [ { :abc => { :def => 'hgi' } } ]
+ [{:abc => {:def => 'hgi'}}],
],
[
'{"abc":[{"def":"hgi"}]}',
- { :abc => [ { :def => 'hgi' } ] }
+ {:abc => [{:def => 'hgi'}]},
],
].each do |example, expected|
MultiJson.decode(example, :symbolize_keys => true).should == expected

0 comments on commit cc6325e

Please sign in to comment.