Sha256: 03700d5e185152101ad2e8a85d6734af60e74cfd08b1483350f0456a964691e5

Contents?: true

Size: 1.25 KB

Versions: 12

Compression:

Stored size: 1.25 KB

Contents

require_relative "spec_helper"
require_relative "../lib/conglomerate"

require "json"

describe Conglomerate::TreeDeserializer do
  it "deserializes collection with error" do
    json = '{"collection":{"version":"1.0","href":"https://apiv3.teamsnap.com/","links":[{"rel":"root","href":"https://apiv3.teamsnap.com/"},{"rel":"self","href":"https://apiv3.teamsnap.com/"}],"error":{"message":"translation missing: en.errors.messages.unauthorized"}}}'
    obj = JSON.parse(json)
    deserializer = Conglomerate::TreeDeserializer.new(obj)
    tree = deserializer.deserialize

    expect(tree.class).to eq(Conglomerate::Collection)
    expect(tree.error.class).to eq(Conglomerate::Error)
    expect(tree.href).to eq("https://apiv3.teamsnap.com/")
  end

  it "deserializes collection with items" do
    obj = {
      "collection" => {
        "version" => "1.0",
        "href" => "http://example.com/",
        "items" => [
          { "href" => "http://example.com/1", "data" => [{
            "name" => "is_unicorn", "value" => true
          }]}
        ]
      }
    }

    deserializer = Conglomerate::TreeDeserializer.new(obj)
    tree = deserializer.deserialize

    expect(
      tree.items.first.data.find { |datum| datum.name == "is_unicorn" }.value
    ).to eq(true)
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
conglomerate-0.16.0 spec/tree_deserializer_spec.rb
conglomerate-0.15.0 spec/tree_deserializer_spec.rb
conglomerate-0.14.0 spec/tree_deserializer_spec.rb
conglomerate-0.13.0 spec/tree_deserializer_spec.rb
conglomerate-0.12.1 spec/tree_deserializer_spec.rb
conglomerate-0.12.0 spec/tree_deserializer_spec.rb
conglomerate-0.11.1 spec/tree_deserializer_spec.rb
conglomerate-0.11.0 spec/tree_deserializer_spec.rb
conglomerate-0.10.0 spec/tree_deserializer_spec.rb
conglomerate-0.9.0 spec/tree_deserializer_spec.rb
conglomerate-0.8.1 spec/tree_deserializer_spec.rb
conglomerate-0.8.0 spec/tree_deserializer_spec.rb