Sha256: 0ea9fc4965dbcb8e8492094b00befb851206817cbdca2a2c320421286cdb108d

Contents?: true

Size: 1.01 KB

Versions: 18

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe 'Resource Building Examples' do
  it 'can deal with arrays' do
    response = Contentful::Response.new raw_fixture('link_array')
    resource = Contentful::ResourceBuilder.new(create_client, response).run

    expect(resource.fields[:links]).to be_a Array
    expect(resource.fields[:links].first).to be_a Contentful::Link
  end

  it 'replaces links with included versions if present' do
    response = Contentful::Response.new raw_fixture('includes')
    resource = Contentful::ResourceBuilder.new(create_client, response).run.first

    expect(resource.fields[:links]).to be_a Array
    expect(resource.fields[:links].first).to be_a Contentful::Entry
  end

  it 'can also reference itself' do
    response = Contentful::Response.new raw_fixture('self_link')
    resource = Contentful::ResourceBuilder.new(create_client, response).run.first

    other_resource = resource.fields[:e]
    expect(other_resource).to be_a Contentful::Entry
    expect(other_resource.fields[:e]).to be resource
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
contentful-1.2.2 spec/resource_building_spec.rb
contentful-1.2.1 spec/resource_building_spec.rb
contentful-1.2.0 spec/resource_building_spec.rb
contentful-1.1.1 spec/resource_building_spec.rb
contentful-1.1.0 spec/resource_building_spec.rb
contentful-1.0.2 spec/resource_building_spec.rb
contentful-1.0.1 spec/resource_building_spec.rb
contentful-1.0.0 spec/resource_building_spec.rb
contentful-0.12.0 spec/resource_building_spec.rb
contentful-0.11.0 spec/resource_building_spec.rb
contentful-0.10.0 spec/resource_building_spec.rb
contentful-0.9.0 spec/resource_building_spec.rb
contentful-0.8.0 spec/resource_building_spec.rb
contentful-0.7.0 spec/resource_building_spec.rb
contentful-0.6.0 spec/resource_building_spec.rb
contentful-0.5.0 spec/resource_building_spec.rb
contentful-0.4.0 spec/resource_building_spec.rb
contentful-0.3.5 spec/resource_building_spec.rb