Sha256: 102e2dfd2afe1c5a70433276875440a6866ffe42f154873bf68dc5ec58ac2ebc

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require_relative '../test_helper'
require 'hyperclient/attributes'

module Hyperclient
  describe Attributes do
    let(:representation) do
      JSON.parse( File.read('test/fixtures/element.json'))
    end

    let(:attributes) do
      Attributes.new(representation)
    end

    it 'does not set _links as an attribute' do
      attributes.wont_respond_to :_links
    end

    it 'does not set _embedded as an attribute' do
      attributes.wont_respond_to :_embedded
    end

    it 'sets normal attributes' do
      attributes.must_respond_to :permitted
      attributes.permitted.must_equal true

      attributes.must_respond_to :title
      attributes.title.must_equal "Real World ASP.NET MVC3"
    end

    # Underscores should be allowed per http://tools.ietf.org/html/draft-kelly-json-hal#appendix-B.4
    it 'sets _hidden_attribute as an attribute' do
      attributes.must_respond_to :_hidden_attribute
      attributes._hidden_attribute.must_equal 'useful value'
    end

    it 'is a collection' do
      Attributes.ancestors.must_include Collection
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyperclient-0.4.0 test/hyperclient/attributes_test.rb
hyperclient-0.3.2 test/hyperclient/attributes_test.rb