From: Tomas Sedovic <[email protected]>

---
 client/specs/hardware_profiles_spec.rb |   16 +++++++-----
 client/specs/images_spec.rb            |   28 +++++++++++----------
 client/specs/initialization_spec.rb    |   14 ++++++----
 client/specs/instance_states_spec.rb   |   30 ++++++++++++----------
 client/specs/instances_spec.rb         |   42 ++++++++++++++++---------------
 client/specs/realms_spec.rb            |   22 +++++++++-------
 client/specs/spec_helper.rb            |    1 +
 client/specs/storage_snapshot_spec.rb  |   20 ++++++++-------
 client/specs/storage_volume_spec.rb    |   20 ++++++++-------
 9 files changed, 105 insertions(+), 88 deletions(-)

diff --git a/client/specs/hardware_profiles_spec.rb 
b/client/specs/hardware_profiles_spec.rb
index 026b146..d11eb36 100644
--- a/client/specs/hardware_profiles_spec.rb
+++ b/client/specs/hardware_profiles_spec.rb
@@ -31,13 +31,15 @@ describe "hardware_profiles" do
   it_should_behave_like "all resources"
 
   it "should allow retrieval of all hardware profiles" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      hardware_profiles = client.hardware_profiles
-      hardware_profiles.should_not be_empty
-      hardware_profiles.each do |hwp|
-        hwp.uri.should_not be_nil
-        hwp.uri.should be_a(String)
-        prop_check(hwp.architecture, String)  if hwp.architecture
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
+        hardware_profiles = client.hardware_profiles
+        hardware_profiles.should_not be_empty
+        hardware_profiles.each do |hwp|
+          hwp.uri.should_not be_nil
+          hwp.uri.should be_a(String)
+          prop_check(hwp.architecture, String)  if hwp.architecture
+        end
       end
     end
   end
diff --git a/client/specs/images_spec.rb b/client/specs/images_spec.rb
index abdc5ee..3b209cd 100644
--- a/client/specs/images_spec.rb
+++ b/client/specs/images_spec.rb
@@ -24,19 +24,21 @@ describe "images" do
   it_should_behave_like "all resources"
 
   it "should allow retrieval of all images" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      images = client.images
-      images.should_not be_empty
-      images.size.should eql( 3 )
-      images.each do |image|
-        image.uri.should_not be_nil
-        image.uri.should be_a(String)
-        image.description.should_not be_nil
-        image.description.should be_a(String)
-        image.architecture.should_not be_nil
-        image.architecture.should be_a(String)
-        image.owner_id.should_not be_nil
-        image.owner_id.should be_a(String)
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
+        images = client.images
+        images.should_not be_empty
+        images.size.should eql( 3 )
+        images.each do |image|
+          image.uri.should_not be_nil
+          image.uri.should be_a(String)
+          image.description.should_not be_nil
+          image.description.should be_a(String)
+          image.architecture.should_not be_nil
+          image.architecture.should be_a(String)
+          image.owner_id.should_not be_nil
+          image.owner_id.should be_a(String)
+        end
       end
     end
   end
diff --git a/client/specs/initialization_spec.rb 
b/client/specs/initialization_spec.rb
index 4f53317..672d858 100644
--- a/client/specs/initialization_spec.rb
+++ b/client/specs/initialization_spec.rb
@@ -28,12 +28,14 @@ describe "initializing the client" do
   end
 
   it "should discover entry points upon connection" do
-    DeltaCloud.new( "name", "password", API_URL ) do |client|
-      client.entry_points[:hardware_profiles].should eql( 
"#{API_URL}/hardware_profiles" )
-      client.entry_points[:images].should            eql( "#{API_URL}/images" )
-      client.entry_points[:instances].should         eql( 
"#{API_URL}/instances" )
-      client.entry_points[:storage_volumes].should   eql( 
"#{API_URL}/storage_volumes" )
-      client.entry_points[:storage_snapshots].should eql( 
"#{API_URL}/storage_snapshots" )
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      DeltaCloud.new( "name", "password", entry_point ) do |client|
+        client.entry_points[:hardware_profiles].should eql( 
"#{API_URL}/hardware_profiles" )
+        client.entry_points[:images].should            eql( 
"#{API_URL}/images" )
+        client.entry_points[:instances].should         eql( 
"#{API_URL}/instances" )
+        client.entry_points[:storage_volumes].should   eql( 
"#{API_URL}/storage_volumes" )
+        client.entry_points[:storage_snapshots].should eql( 
"#{API_URL}/storage_snapshots" )
+      end
     end
   end
 
diff --git a/client/specs/instance_states_spec.rb 
b/client/specs/instance_states_spec.rb
index 49b5a35..c79c273 100644
--- a/client/specs/instance_states_spec.rb
+++ b/client/specs/instance_states_spec.rb
@@ -33,23 +33,25 @@ describe "instance-states" do
   it_should_behave_like "all resources"
 
   it "should allow retrieval of instance-state information" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance_states = client.instance_states
-      instance_states.should_not be_nil
-      instance_states.should_not be_empty
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
+        instance_states = client.instance_states
+        instance_states.should_not be_nil
+        instance_states.should_not be_empty
 
-      instance_states[0].name.should eql( 'start' )
-      instance_states[0].transitions.size.should eql( 1 )
-      instance_states[0].transitions[0].should_not be_auto
+        instance_states[0].name.should eql( 'start' )
+        instance_states[0].transitions.size.should eql( 1 )
+        instance_states[0].transitions[0].should_not be_auto
 
-      instance_states[1].name.should eql( 'pending' )
-      instance_states[1].transitions.size.should eql( 1 )
-      instance_states[1].transitions[0].should be_auto
+        instance_states[1].name.should eql( 'pending' )
+        instance_states[1].transitions.size.should eql( 1 )
+        instance_states[1].transitions[0].should be_auto
 
-      instance_states[2].name.should eql( 'running' )
-      instance_states[2].transitions.size.should eql( 2 )
-      includes_transition( instance_states[2].transitions, :reboot, :running 
).should be_true
-      includes_transition( instance_states[2].transitions, :stop, :stopped 
).should be_true
+        instance_states[2].name.should eql( 'running' )
+        instance_states[2].transitions.size.should eql( 2 )
+        includes_transition( instance_states[2].transitions, :reboot, :running 
).should be_true
+        includes_transition( instance_states[2].transitions, :stop, :stopped 
).should be_true
+      end
     end
   end
 
diff --git a/client/specs/instances_spec.rb b/client/specs/instances_spec.rb
index 8729cc0..c4995ae 100644
--- a/client/specs/instances_spec.rb
+++ b/client/specs/instances_spec.rb
@@ -24,26 +24,28 @@ describe "instances" do
   it_should_behave_like "all resources"
 
   it "should allow retrieval of all instances" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instances = client.instances
-      instances.should_not be_empty
-      instances.each do |instance|
-        instance.uri.should_not be_nil
-        instance.uri.should be_a( String )
-        instance.owner_id.should_not be_nil
-        instance.owner_id.should be_a( String )
-        instance.image.should_not be_nil
-        instance.image.should be_a( DeltaCloud::API::Image )
-        instance.hardware_profile.should_not be_nil
-        instance.hardware_profile.should be_a( 
DeltaCloud::API::HardwareProfile )
-        instance.state.should_not be_nil
-        instance.state.should be_a( String )
-        instance.public_addresses.should_not be_nil
-        instance.public_addresses.should_not be_empty
-        instance.public_addresses.should be_a( Array )
-        instance.private_addresses.should_not be_nil
-        instance.private_addresses.should_not be_empty
-        instance.private_addresses.should be_a( Array )
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
+        instances = client.instances
+        instances.should_not be_empty
+        instances.each do |instance|
+          instance.uri.should_not be_nil
+          instance.uri.should be_a( String )
+          instance.owner_id.should_not be_nil
+          instance.owner_id.should be_a( String )
+          instance.image.should_not be_nil
+          instance.image.should be_a( DeltaCloud::API::Image )
+          instance.hardware_profile.should_not be_nil
+          instance.hardware_profile.should be_a( 
DeltaCloud::API::HardwareProfile )
+          instance.state.should_not be_nil
+          instance.state.should be_a( String )
+          instance.public_addresses.should_not be_nil
+          instance.public_addresses.should_not be_empty
+          instance.public_addresses.should be_a( Array )
+          instance.private_addresses.should_not be_nil
+          instance.private_addresses.should_not be_empty
+          instance.private_addresses.should be_a( Array )
+        end
       end
     end
   end
diff --git a/client/specs/realms_spec.rb b/client/specs/realms_spec.rb
index 8b1175a..241fb5c 100644
--- a/client/specs/realms_spec.rb
+++ b/client/specs/realms_spec.rb
@@ -23,16 +23,18 @@ describe "realms" do
   it_should_behave_like "all resources"
 
   it "should allow retrieval of all realms" do
-    DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      realms = client.realms
-      realms.should_not be_empty
-      realms.each do |realm|
-        realm.uri.should_not be_nil
-        realm.uri.should be_a(String)
-        realm.id.should_not be_nil
-        realm.id.should be_a(String)
-        realm.name.should_not be_nil
-        realm.name.should be_a(String)
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      DeltaCloud.new( API_NAME, API_PASSWORD, entry_point ) do |client|
+        realms = client.realms
+        realms.should_not be_empty
+        realms.each do |realm|
+          realm.uri.should_not be_nil
+          realm.uri.should be_a(String)
+          realm.id.should_not be_nil
+          realm.id.should be_a(String)
+          realm.name.should_not be_nil
+          realm.name.should be_a(String)
+        end
       end
     end
   end
diff --git a/client/specs/spec_helper.rb b/client/specs/spec_helper.rb
index 81ee943..b4cb95c 100644
--- a/client/specs/spec_helper.rb
+++ b/client/specs/spec_helper.rb
@@ -33,6 +33,7 @@ API_PORT = api_port
 API_PATH = '/api'
 
 API_URL = "http://#{API_HOST}:#{API_PORT}#{API_PATH}";
+API_URL_REDIRECT = "http://#{API_HOST}:#{API_PORT}";
 API_NAME     = 'mockuser'
 API_PASSWORD = 'mockpassword'
 
diff --git a/client/specs/storage_snapshot_spec.rb 
b/client/specs/storage_snapshot_spec.rb
index 8281871..f1ae43b 100644
--- a/client/specs/storage_snapshot_spec.rb
+++ b/client/specs/storage_snapshot_spec.rb
@@ -24,15 +24,17 @@ describe "storage snapshot" do
   it_should_behave_like "all resources"
 
   it "allow retrieval of all storage volumes owned by the current user" do
-    client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
-    client.connect do |client|
-      storage_snapshots = client.storage_snapshots
-      storage_snapshots.should_not be_nil
-      storage_snapshots.should_not be_empty
-      ids = storage_snapshots.collect{|e| e.id}
-      ids.size.should eql( 2 )
-      ids.should include( 'snap2' )
-      ids.should include( 'snap3' )
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      client = DeltaCloud.new( API_NAME, API_PASSWORD, entry_point )
+      client.connect do |client|
+        storage_snapshots = client.storage_snapshots
+        storage_snapshots.should_not be_nil
+        storage_snapshots.should_not be_empty
+        ids = storage_snapshots.collect{|e| e.id}
+        ids.size.should eql( 2 )
+        ids.should include( 'snap2' )
+        ids.should include( 'snap3' )
+      end
     end
   end
 
diff --git a/client/specs/storage_volume_spec.rb 
b/client/specs/storage_volume_spec.rb
index ab81b62..f57d9c1 100644
--- a/client/specs/storage_volume_spec.rb
+++ b/client/specs/storage_volume_spec.rb
@@ -24,15 +24,17 @@ describe "storage volumes" do
   it_should_behave_like "all resources"
 
   it "allow retrieval of all storage volumes owned by the current user" do
-    client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
-    client.connect do |client|
-      storage_volumes = client.storage_volumes
-      storage_volumes.should_not be_nil
-      storage_volumes.should_not be_empty
-      ids = storage_volumes.collect{|e| e.id}
-      ids.size.should eql( 2 )
-      ids.should include( 'vol2' )
-      ids.should include( 'vol3' )
+    [API_URL, API_URL_REDIRECT].each do |entry_point|
+      client = DeltaCloud.new( API_NAME, API_PASSWORD, entry_point )
+      client.connect do |client|
+        storage_volumes = client.storage_volumes
+        storage_volumes.should_not be_nil
+        storage_volumes.should_not be_empty
+        ids = storage_volumes.collect{|e| e.id}
+        ids.size.should eql( 2 )
+        ids.should include( 'vol2' )
+        ids.should include( 'vol3' )
+      end
     end
   end
 
-- 
1.7.2.3

Reply via email to