Sha256: 8cc9b4746e4577c6d9c5fd75eac1ba25ddfeaf6b6f58effbb8d59df82ea9d094

Contents?: true

Size: 1.35 KB

Versions: 14

Compression:

Stored size: 1.35 KB

Contents

# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')

describe "Yajl" do
  context "dump" do
    it "should exist as a class-method" do
      Yajl.should respond_to(:dump)
    end

    it "should be able to encode to a string" do
      Yajl.dump({:a => 1234}).should eql('{"a":1234}')
    end

    it "should be able to encode to an IO" do
      io = StringIO.new
      Yajl.dump({:a => 1234}, io)
      io.rewind
      io.read.should eql('{"a":1234}')
    end

    it "should be able to encode with a block supplied" do
      Yajl.dump({:a => 1234}) do |chunk|
        chunk.should eql('{"a":1234}')
      end
    end
  end

  context "load" do
    it "should exist as a class-method" do
      Yajl.should respond_to(:load)
    end

    it "should be able to parse from a string" do
      Yajl.load('{"a":1234}').should eql({"a" => 1234})
    end

    it "should be able to parse from an IO" do
      io = StringIO.new('{"a":1234}')
      Yajl.load(io).should eql({"a" => 1234})
    end

    it "should be able to parse from a string with a block supplied" do
      Yajl.load('{"a":1234}') do |h|
        h.should eql({"a" => 1234})
      end
    end

    it "should be able to parse from an IO with a block supplied" do
      io = StringIO.new('{"a":1234}')
      Yajl.load(io) do |h|
        h.should eql({"a" => 1234})
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
yajl-ruby-0.8.3 spec/global/global_spec.rb
yajl-ruby-0.8.2 spec/global/global_spec.rb
yajl-ruby-0.8.1 spec/global/global_spec.rb
yajl-ruby-0.8.0 spec/global/global_spec.rb
yajl-ruby-0.7.9 spec/global/global_spec.rb
yajl-ruby-0.7.8 spec/global/global_spec.rb
yajl-ruby-0.7.7 spec/global/global_spec.rb
benofsky-yajl-ruby-0.7.7 spec/global/global_spec.rb
benofsky-yajl-ruby-0.7.6 spec/global/global_spec.rb
yajl-ruby-0.7.6 spec/global/global_spec.rb
yajl-ruby-0.7.5 spec/global/global_spec.rb
yajl-ruby-0.7.4 spec/global/global_spec.rb
yajl-ruby-0.7.3 spec/global/global_spec.rb
yajl-ruby-0.7.2 spec/global/global_spec.rb