Sha256: 7d9582407cc90616360bce99cc2f19dc9fd696834c94dfcef078c5d64c598a30

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

require 'spec_helper'

describe Jsonify::Generate do
  let(:links) do
    { :links => 
       [
         {:rel => 'foo', :href => 'goo'},
         {:rel => 'bar', :href => 'baz'}
       ]
    }
  end
  it 'should build json' do
    json = Jsonify::Generate
    result = json.value links
    result.evaluate.should == '{"links":[{"rel":"foo","href":"goo"},{"rel":"bar","href":"baz"}]}'
  end

  describe 'complex example' do
    let(:jsonifier) { Jsonify::Generate }
    
    it 'should work' do
      json = jsonifier.object_value( 
        {"links" =>
          jsonifier.array_value([
            jsonifier.object_value( {"rel" => "foo", "href" => "goo"} ),
            jsonifier.object_value( {"rel" => "bar", "href" => "baz"} )
          ])
        }
      )
      json.evaluate.should == "{\"links\":[{\"rel\":\"foo\",\"href\":\"goo\"},{\"rel\":\"bar\",\"href\":\"baz\"}]}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonify-0.0.1 spec/generate_spec.rb