Sha256: 981fb65582b0d0f0937ad83cd7ee53fedd179aab1be7b2030965cdb5ce72dcbd

Contents?: true

Size: 1.06 KB

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
hyperclient-0.8.1 test/hyperclient/attributes_test.rb
hyperclient-0.8.0 test/hyperclient/attributes_test.rb
hyperclient-0.7.2 test/hyperclient/attributes_test.rb
hyperclient-0.7.1 test/hyperclient/attributes_test.rb
hyperclient-0.7.0 test/hyperclient/attributes_test.rb
hyperclient-0.6.1 test/hyperclient/attributes_test.rb
hyperclient-0.5.0 test/hyperclient/attributes_test.rb