Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Flesh out login specs

  • Loading branch information...
commit 07177c1aaeb9d558488df239693b7cb253860e7c 1 parent 0095625
freeformz authored geemus committed
Showing with 42 additions and 7 deletions.
  1. +7 −0 spec/vcloud/requests/login_spec.rb
  2. +35 −7 spec/vcloud/spec_helper.rb
View
7 spec/vcloud/requests/login_spec.rb
@@ -8,6 +8,13 @@
if Fog.mocking?
describe Fog::Vcloud, :type => :mock_vcloud_request do
it_should_behave_like "real or mock login requests"
+
+ describe "#body" do
+ subject { @vcloud.login.body }
+ its(:Org) { should == { :type => "application/vnd.vmware.vcloud.org+xml",
+ :href => @mock_organization[:info][:href],
+ :name => @mock_organization[:info][:name]} }
+ end
end
else
describe Fog::Vcloud, :type => :vcloud_request do
View
42 spec/vcloud/spec_helper.rb
@@ -102,17 +102,27 @@ def arrayify(item)
its(:headers) { should include "Set-Cookie" }
- it { should have_headers_denoting_a_content_type_of "application/vnd.vmware.vcloud.orgslist+xml" }
-
describe "#body" do
subject { @login.body }
- it { should have(4).organizations }
-
+ it { should have(4).items }
it_should_behave_like "it has the standard vcloud v0.8 xmlns attributes" # 3 keys
- its(:Org) { should == { :type => "application/vnd.vmware.vcloud.org+xml",
- :href => @mock_organization[:info][:href],
- :name => @mock_organization[:info][:name]} }
+ it { should include(:Org) }
+
+ describe ":Org" do
+ subject { arrayify(@login.body[:Org]) }
+
+ specify do
+ subject.each do |org|
+ org.should include(:type)
+ org[:type].should be_of_type "application/vnd.vmware.vcloud.org+xml"
+ org.should include(:name)
+ org[:name].should be_an_instance_of String
+ org.should include(:href)
+ org[:href].should be_a_url
+ end
+ end
+ end
end
end
end
@@ -353,3 +363,21 @@ def setup_ecloud_mock_data
actual.is_a?(Hash) || actual.is_a?(Array)
end
end
+
+Spec::Matchers.define :be_a_known_vmware_type do
+ match do |actual|
+ ["application/vnd.vmware.vcloud.org+xml"].include?(actual)
+ end
+end
+
+Spec::Matchers.define :be_of_type do |type|
+ match do |actual|
+ actual == type ||
+ if actual.is_a?(Hash) && actual[:type]
+ actual[:type] == type
+ end ||
+ if actual.respond_to(:type)
+ actual.type == type
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.