Sha256: 71ea9eedcaadcf484c5668a3e9a2b025ed88ced674ba4d875e0d66b6240a50cd

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

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

    it "parses data correctly" do
      data = {
        name: "When I am small"
      }
      resource = GrooveHQ::Resource.new(self, 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(self, 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(self, data)
      expect(resource.rels[:assignee]).to be_instance_of(GrooveHQ::Relation)
    end

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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
groovehq-1.0.2 spec/groovehq/resource_spec.rb
groovehq-1.0.0 spec/groovehq/resource_spec.rb