Sha256: 5072021af3ee227c6c330f3fac413632c2cd633b37f9f7cada5341e122c88121

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require 'rubygems'
require 'require_relative' if RUBY_VERSION < '1.9'

require_relative File.join('..', 'common.rb')

describe Deltacloud::Collections::HardwareProfiles do

  before do
    def app; run_frontend; end
    authorize 'mockuser', 'mockpassword'
    @collection = Deltacloud::Collections.collection(:hardware_profiles)
  end

  it 'has index operation' do
    @collection.operation(:index).must_equal Sinatra::Rabbit::HardwareProfilesCollection::IndexOperation
  end

  it 'has show operation' do
    @collection.operation(:show).must_equal Sinatra::Rabbit::HardwareProfilesCollection::ShowOperation
  end

  it 'returns list of hardware profiles in various formats with index operation' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/hardware_profiles'
      status.must_equal 200
    end
  end

  it 'returns details about hardware profile in various formats with show operation' do
    formats.each do |format|
      header 'Accept', format
      get root_url + '/hardware_profiles/m1-small'
      status.must_equal 200
    end
  end

  it 'returns details for various hardware profile configurations' do
    get root_url + '/hardware_profiles'
    status.must_equal 200
    (xml/'hardware_profiles/hardware_profile').each do |hwp|
      get root_url + '/hardware_profiles/' + hwp[:id]
      status.must_equal 200
      xml.root[:id].must_equal hwp[:id]
    end
  end

  it 'reports 404 when querying non-existing hardware profile' do
    get root_url + '/hardware_profiles/unknown'
    status.must_equal 404
  end

  it 'properly serialize attributes in JSON' do
    check_json_serialization_for :hardware_profile, 'm1-small'
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deltacloud-core-1.1.1 tests/deltacloud/collections/hardware_profiles_collection_test.rb
deltacloud-core-1.1.0 tests/deltacloud/collections/hardware_profiles_collection_test.rb