Sha256: 7daaf08fbd5fd06c80af20eaccbb60def3880f12248910fcf122e96ff2180130
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
require_relative '../test_helper' require 'hyperclient/response' module Hyperclient describe Discoverer do before do Resource.entry_point = 'http://api.myexample.org/' end let (:response) do JSON.parse(File.read('test/fixtures/element.json')) end describe 'each' do it 'iterates between resources' do discoverer = Discoverer.new(response['_links']) discoverer.each do |resource| resource.must_be_kind_of Resource end end end describe '[]' do it 'fetches a resource' do discoverer = Discoverer.new(response['_links']) discoverer['filter'].must_be_kind_of Resource end end describe 'resources' do it 'does not include self as a resource' do discoverer = Discoverer.new(response['_links']) lambda { discoverer.self }.must_raise NoMethodError end it 'builds single resources' do discoverer = Discoverer.new(response['_links']) discoverer.filter.must_be_kind_of Resource end it 'builds collection resources' do discoverer = Discoverer.new(response['_embedded']) discoverer.episodes.must_be_kind_of Array end it 'also builds elements in collection resources' do discoverer = Discoverer.new(response['_embedded']) discoverer.episodes.first.must_be_kind_of Resource end it 'initializes resources with its URL' do discoverer = Discoverer.new(response['_links']) discoverer.filter.url.wont_be_empty end it 'initializes resources with the response' do discoverer = Discoverer.new(response['_embedded']) discoverer.author.attributes.wont_be_empty end it 'initializes resources with its name' do discoverer = Discoverer.new(response['_links']) discoverer.filter.name.wont_be_empty end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hyperclient-0.0.3 | test/hyperclient/discoverer_test.rb |
hyperclient-0.0.2 | test/hyperclient/discoverer_test.rb |