Sha256: 572252904c40aedd77be9b8490df785848c3cb310f73c3124789420fa104eac5
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 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 "XToJson" do context 'engines' do it 'should default to the best available gem' do require 'yajl' XToJson.engine.name.should == 'XToJson::Engines::Yajl' end it 'should be settable via a symbol' do XToJson.engine = :yajl XToJson.engine.name.should == 'XToJson::Engines::Yajl' end it 'should be settable via a class' do XToJson.engine = MockDecoder XToJson.engine.name.should == 'MockDecoder' end end %w(active_support json_gem json_pure yajl).each do |engine| context engine do before do XToJson.engine = engine end describe '.encode' do it 'should write decodable JSON' do [ {'abc' => 'def'}, [1, 2, 3, "4"] ].each do |example| XToJson.decode(XToJson.encode(example)).should == example end end end describe '.decode' do it 'should properly decode some json' do XToJson.decode('{"abc":"def"}').should == {'abc' => 'def'} end it 'should allow for symbolization of keys' do XToJson.decode('{"abc":{"def":"hgi"}}', :symbolize_keys => true).should == {:abc => {:def => 'hgi'}} end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
x_to_json-0.0.1 | spec/x_to_json_spec.rb |