Sha256: 99f6ad4c20055e6ecaae3ee87e692301390c520e81168a668df7d0c5e5aadaa1
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') class MockDecoder def self.decode(string, options = {}) {'abc' => 'def'} end def self.encode(string) '{"abc":"def"}' end end describe "MultiJson" do context 'engines' do it 'should default to the best available gem' do require 'yajl' MultiJson.engine.name.should == 'MultiJson::Engines::Yajl' end it 'should be settable via a symbol' do MultiJson.engine = :yajl MultiJson.engine.name.should == 'MultiJson::Engines::Yajl' end it 'should be settable via a class' do MultiJson.engine = MockDecoder MultiJson.engine.name.should == 'MockDecoder' end end %w(active_support json_gem json_pure yajl).each do |engine| context engine do before do MultiJson.engine = engine end describe '.encode' do it 'should write decodable JSON' do [ {'abc' => 'def'}, [1, 2, 3, "4"] ].each do |example| MultiJson.decode(MultiJson.encode(example)).should == example end end end describe '.decode' do it 'should properly decode some json' do MultiJson.decode('{"abc":"def"}').should == {'abc' => 'def'} end it 'should allow for symbolization of keys' do MultiJson.decode('{"abc":{"def":"hgi"}}', :symbolize_keys => true).should == {:abc => {:def => 'hgi'}} end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
multi_json-0.0.3 | spec/x_to_json_spec.rb |
multi_json-0.0.2 | spec/x_to_json_spec.rb |