Sha256: 480efa0329a98fefe83cdf2d879a85b7a4e8bfd6d3a3aaf919754d5975094515

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'spec/integration/integration_spec_helper'

describe Nucleus::API::V1::Vendors do
  after { Nucleus::TestDataGenerator.clean }

  let!(:vendor_a) { create(:vendor) }
  let!(:vendor_b) { create(:vendor) }
  let!(:provider_a) { create(:provider, vendor: vendor_a.id) }
  let!(:provider_b) { create(:provider, vendor: vendor_a.id) }
  let!(:provider_c) { create(:provider, vendor: vendor_b.id) }
  let!(:endpoint_a) { create(:endpoint, provider: provider_a.id) }
  let!(:endpoint_b) { create(:endpoint, provider: provider_b.id) }

  context 'GET /vendors response' do
    before { get '/vendors' }
    include_examples 'a valid GET request'
    it 'has vendor-list like structure' do
      expect_json_types(size: :int, vendors: :array_of_objects, _links: :object)
    end

    # TODO: contains all required fields

    it 'shows the retrieved number of vendors' do
      expect(json_body[:size]).to eq 2
      expect_json_sizes(vendors: 2)
    end
    it 'lists all vendors' do
      expect(json_body[:vendors]).to_not be_nil
      expect(json_body[:vendors][0][:id]).to eq vendor_a.id
      expect(json_body[:vendors][1][:id]).to eq vendor_b.id
    end
  end

  context 'GET /vendors/:id' do
    before { get "/vendors/#{vendor_a.id}" }
    include_examples 'a valid GET request'
    it 'has the structure of an vendor object' do
      expect_json_types(id: :string, name: :string, created_at: :date, updated_at: :date,
                        providers: :array_of_objects, _links: :object)
    end
    it 'contains the requested vendor' do
      expect(json_body[:id]).to eq vendor_a.id
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nucleus-0.3.1 spec/integration/api/vendors_spec.rb
nucleus-0.2.0 spec/integration/api/vendors_spec.rb
nucleus-0.1.0 spec/integration/api/vendors_spec.rb