Sha256: c60af345fc3d83dccc576608ebde63b0fcc4ee4eb78e986c686e4272ae24ca05

Contents?: true

Size: 1.37 KB

Versions: 13

Compression:

Stored size: 1.37 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')

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

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

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

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

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

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

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

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

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/global/global_spec.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/global/global_spec.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/global/global_spec.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/yajl-ruby-1.4.3/spec/global/global_spec.rb
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/yajl-ruby-1.4.3/spec/global/global_spec.rb
yajl-ruby-1.4.3 spec/global/global_spec.rb
yajl-ruby-1.4.2 spec/global/global_spec.rb
yajl-ruby-1.4.1 spec/global/global_spec.rb
yajl-ruby-1.4.0 spec/global/global_spec.rb
yajl-ruby-1.3.1 spec/global/global_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/spec/global/global_spec.rb
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/yajl-ruby-1.3.0/spec/global/global_spec.rb
yajl-ruby-1.3.0 spec/global/global_spec.rb