2011-02-17 10:44:46 -08:00
|
|
|
require 'ecloud/spec_helper'
|
2010-05-02 21:46:43 -07:00
|
|
|
|
2010-06-18 07:58:09 +08:00
|
|
|
if Fog.mocking?
|
2011-02-17 10:44:46 -08:00
|
|
|
describe Fog::Ecloud, :type => :mock_tmrk_ecloud_request do
|
2010-06-18 07:58:09 +08:00
|
|
|
subject { @vcloud }
|
|
|
|
|
2011-02-15 13:47:14 -08:00
|
|
|
it { should respond_to(:get_organization) }
|
2010-06-18 07:58:09 +08:00
|
|
|
|
|
|
|
describe "#get_organization" do
|
|
|
|
context "with a valid organization uri" do
|
|
|
|
before { @organization = @vcloud.get_organization(@vcloud.default_organization_uri) }
|
|
|
|
subject { @organization }
|
|
|
|
|
|
|
|
it_should_behave_like "all responses"
|
2011-02-15 13:47:14 -08:00
|
|
|
it { should have_headers_denoting_a_content_type_of("application/vnd.vmware.vcloud.org+xml") }
|
2010-06-18 07:58:09 +08:00
|
|
|
|
|
|
|
describe "#body" do
|
|
|
|
subject { @organization.body }
|
|
|
|
|
|
|
|
|
|
|
|
let(:links) { subject[:Link] }
|
|
|
|
|
|
|
|
it { should have(6).keys }
|
|
|
|
|
|
|
|
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
|
2011-02-15 13:47:14 -08:00
|
|
|
it { should have_key_with_value(:href, @mock_organization.href)}
|
|
|
|
it { should have_key_with_value(:name, @mock_organization.name) }
|
|
|
|
it { should have_key_with_array(:Link, @mock_organization.vdcs.map { |vdc|
|
2010-06-18 07:58:09 +08:00
|
|
|
[{ :type => "application/vnd.vmware.vcloud.vdc+xml",
|
2010-10-18 07:06:44 +08:00
|
|
|
:href => vdc.href,
|
|
|
|
:name => vdc.name,
|
2010-06-18 07:58:09 +08:00
|
|
|
:rel => "down" },
|
|
|
|
{ :type => "application/vnd.vmware.vcloud.catalog+xml",
|
2010-10-18 07:06:44 +08:00
|
|
|
:href => vdc.catalog.href,
|
|
|
|
:name => vdc.catalog.name,
|
2010-06-18 07:58:09 +08:00
|
|
|
:rel => "down" },
|
|
|
|
{ :type => "application/vnd.vmware.vcloud.tasksList+xml",
|
2010-10-18 07:06:44 +08:00
|
|
|
:href => vdc.task_list.href,
|
|
|
|
:name => vdc.task_list.name,
|
2010-06-18 07:58:09 +08:00
|
|
|
:rel => "down" }]
|
2011-02-15 13:47:14 -08:00
|
|
|
}.flatten) }
|
2010-06-18 07:58:09 +08:00
|
|
|
|
|
|
|
end
|
2010-05-02 21:46:43 -07:00
|
|
|
end
|
2010-06-18 07:58:09 +08:00
|
|
|
context "with an organization uri that doesn't exist" do
|
|
|
|
subject { lambda { @vcloud.get_organization(URI.parse('https://www.fakey.com/api/v0.8/org/999')) } }
|
2011-02-15 13:47:14 -08:00
|
|
|
it_should_behave_like("a request for a resource that doesn't exist")
|
2010-05-02 21:46:43 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|