Sha256: 0e023080817f85e46a260bb759d287cbc1d3d61e99079cbe1f50b7ca6a452d5e

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe Voog::API::ElementDefinitions do

  let(:client) { voog_client }

  describe '#element_definitions' do
    before do
      request_fixture(:get, 'element_definitions', fixture: 'element_definitions/element_definitions')
    end

    it 'returns a list of element_definitions' do
      expect(client.element_definitions.length).to eql(2)
    end
  end

  describe '#element_definition' do
    before do
      request_fixture(:get, 'element_definitions/2', fixture: 'element_definitions/element_definition')
    end

    it 'returns a single element_definition' do
      expect(client.element_definition(2).title).to eq('Book')
    end

    it 'returns a element_definition with the same id as in the request' do
      expect(client.element_definition(2).id).to eq(2)
    end
  end

  describe '#delete_element_definition' do

    before do
      request_fixture(:delete, 'element_definitions/2')
    end

    it 'calls delete method on element_definition' do
      client.delete_element_definition(2)
      assert_requested :delete, 'http://voog.test/admin/api/element_definitions/2'
    end
  end

  describe '#update_element_definition' do

    before do
      request_fixture(:put, 'element_definitions/2', request: {body: {title: 'Fiction book'}}, response: {body: '{"id": 2, "title": "Fiction book"}'})
    end

    it 'responds with new title' do
      expect(client.update_element_definition(2, title: 'Fiction book').title).to eq('Fiction book')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
voog_api-0.0.16 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.15 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.14 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.13 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.12 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.11 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.10 spec/voog_api/api/element_definitions_spec.rb
voog_api-0.0.7 spec/voog_api/api/element_definitions_spec.rb