Sha256: e562d28e226ac596ad9623529ed56a73454a1e8a4a4ec134ecbcd0b66e4586e8

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe GrooveHQ::Resource do

  let(:client) { GrooveHQ::Client.new("phantogram") }

  context "#data" do

    it "returns empty data for invalid input" do
      resource = GrooveHQ::ResourceCollection.new(client, "")
      expect(resource.count).to eql(0)
    end

    it "parses data correctly" do
      data = {
        tickets: [ { name: "When I am small" } ]
      }
      resource = GrooveHQ::ResourceCollection.new(client, data)
      expect(resource.first.name).to eql "When I am small"
    end

  end

  context "#rels" do

    it "parses relations correctly" do
      data = {
        tickets: [],
        meta: {
          pagination: {
            current_page: 1,
            total_pages: 23,
            total_count: 23,
            next_page: "http://api.groovehq.dev/v1/tickets?page=2"
          }
        }
      }.stringify_keys

      resource = GrooveHQ::ResourceCollection.new(client, data)
      expect(resource.rels[:next]).to be_instance_of(GrooveHQ::Relation)
      expect(resource.rels[:next].href).to eq("http://api.groovehq.dev/v1/tickets?page=2")
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
groovehq-1.0.5 spec/groovehq/resource_collection_spec.rb