Sha256: d8875f551a4012d729a415e06a8624792e108e5bc6823e84ac2f6b84ce15c837

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 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::Resource.new(client, "")
      expect(resource.data.to_h).to eql({})
    end

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

    it "adds getters for data" do
      data = {
        name: "When I am small"
      }
      resource = GrooveHQ::Resource.new(client, data)
      expect(resource.name).to eql "When I am small"
    end
  end

  context "#rels" do

    it "parses relations correctly" do
      data = {
        links: {
          assignee: {
            href: "https://api.groovehq.com/v1/agents/matt@groovehq.com"
          }
        }
      }
      resource = GrooveHQ::Resource.new(client, data)
      expect(resource.rels[:assignee]).to be_instance_of(GrooveHQ::Relation)
      expect(resource.rels[:assignee].href).to eq("https://api.groovehq.com/v1/agents/matt@groovehq.com")
    end

    it "parses self relation correctly" do
      data = {
        href: "https://api.groovehq.com/v1/agents/matt@groovehq.com"
      }
      resource = GrooveHQ::Resource.new(client, data)
      expect(resource.rels[:self]).to be_instance_of(GrooveHQ::Relation)
      expect(resource.rels[:self].href).to eq("https://api.groovehq.com/v1/agents/matt@groovehq.com")
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
groovehq-1.0.7 spec/groovehq/resource_spec.rb
groovehq-1.0.6 spec/groovehq/resource_spec.rb
groovehq-1.0.5 spec/groovehq/resource_spec.rb
groovehq-1.0.4 spec/groovehq/resource_spec.rb
groovehq-1.0.3 spec/groovehq/resource_spec.rb