Sha256: 77f2ba017bd35ba21a9bec909b795575279efc1074bb43f8806bf8d743a61ba0

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

require_relative '../test_helper'
require 'hyperclient'

module Hyperclient
  describe ResourceCollection do
    let(:entry_point) { stub('Entry point', config: { base_uri: '/' }) }

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

    let(:resources) do
      ResourceCollection.new(representation['_embedded'], entry_point)
    end

    it 'is a collection' do
      _(ResourceCollection.ancestors).must_include Collection
    end

    it 'initializes the collection with resources' do
      _(resources).must_respond_to :author
      _(resources).must_respond_to :episodes
    end

    it 'returns resource objects for each resource' do
      _(resources.author).must_be_kind_of Resource
    end

    it 'also builds arras of resource' do
      _(resources.episodes).must_be_kind_of Array
      _(resources.episodes.first).must_be_kind_of Resource
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hyperclient-2.0.0 test/hyperclient/resource_collection_test.rb
hyperclient-1.0.1 test/hyperclient/resource_collection_test.rb