Sha256: 1ecfcee8e487286fe21817897649b3fbca42f8ba6b39e1926d7ce217d68a112b

Contents?: true

Size: 1012 Bytes

Versions: 6

Compression:

Stored size: 1012 Bytes

Contents

require 'spec_helper'

describe Jsonify::JsonValue do

  describe Jsonify::JsonPair do
    let(:pair) { Jsonify::JsonPair.new('key','value') }
    it 'should be constructed of a key and value' do
      pair.key.should == 'key'
    end
    it 'should evaluate to key:value' do
      pair.to_json.should == "\"key\":\"value\""
    end
  end

  describe Jsonify::JsonTrue do
    it 'should have a value of true' do
      Jsonify::JsonTrue.new.to_json.should == 'true'
    end
  end

  describe Jsonify::JsonFalse do
    it 'should have a value of false' do
      Jsonify::JsonFalse.new.to_json.should == 'false'
    end
  end

  describe Jsonify::JsonNull do
    it 'should have a value of true' do
      Jsonify::JsonNull.new.to_json.should == 'null'
    end
  end

  describe 'strings' do
    it 'should quote the value' do
      'foo'.to_json.should == "\"foo\""
    end
    it 'should encode unicode' do
      unicode = 'goober'.concat(16)
      unicode.to_json.should == "\"goober\\u0010\""
    end
  end


end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jsonify-0.2.0 spec/json_value_spec.rb
jsonify-0.1.3 spec/json_value_spec.rb
jsonify-0.1.2 spec/json_value_spec.rb
jsonify-0.1.1 spec/json_value_spec.rb
jsonify-0.1.0 spec/json_value_spec.rb
jsonify-0.0.9 spec/json_value_spec.rb