incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962090 - in /incubator/deltacloud/trunk/client-ruby/specs: initialization_spec.rb instance_states_spec.rb spec_helper.rb
Date Thu, 08 Jul 2010 23:22:17 GMT
Author: lutter
Date: Thu Jul  8 23:22:16 2010
New Revision: 962090

URL: http://svn.apache.org/viewvc?rev=962090&view=rev
Log:
Pull API_HOST and API_PORT from environment, with reasonable defaults if not set.
Remove fancy matcher from rspec.

Modified:
    incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb
    incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb
    incubator/deltacloud/trunk/client-ruby/specs/spec_helper.rb

Modified: incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb?rev=962090&r1=962089&r2=962090&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/initialization_spec.rb Thu Jul  8 23:22:16
2010
@@ -3,10 +3,10 @@ require 'specs/spec_helper'
 describe "initializing the client" do
 
   it "should parse valid API URIs" do
-    client = DeltaCloud.new( "name", "password", API_URL )
-    client.api_host.should eql( "localhost" )
-    client.api_port.should eql( 3000 )
-    client.api_path.should eql( "/api" )
+    client = DeltaCloud.new( API_NAME, API_PASSWORD, API_URL )
+    client.api_host.should eql( API_HOST )
+    client.api_port.should eql( API_PORT.to_i )
+    client.api_path.should eql( API_PATH )
   end
 
   it "should discover entry points upon connection" do

Modified: incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb?rev=962090&r1=962089&r2=962090&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb Thu Jul  8 23:22:16
2010
@@ -1,12 +1,14 @@
 
 require 'specs/spec_helper'
 
+=begin
 Spec::Matchers.define :include_transition do |action,to|
   match do |transitions|
     found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s
}
     ! found.nil?
   end
 end
+=end
 
 describe "instance-states" do
 
@@ -24,8 +26,8 @@ describe "instance-states" do
 
       instance_states[1].name.should eql( 'running' )
       instance_states[1].transitions.size.should eql( 2 )
-      instance_states[1].transitions.should include_transition( :reboot, :running )
-      instance_states[1].transitions.should include_transition( :stop, :terminated )
+      includes_transition( instance_states[1].transitions, :reboot, :running ).should be_true
+      includes_transition( instance_states[1].transitions, :stop, :terminated ).should be_true
     end
   end 
 
@@ -40,10 +42,15 @@ describe "instance-states" do
       instance_state = client.instance_state( :running )
       instance_state.name.should eql( 'running' )
       instance_state.transitions.size.should eql( 2 )
-      instance_state.transitions.should include_transition( :reboot, :running )
-      instance_state.transitions.should include_transition( :stop, :terminated )
+      includes_transition( instance_state.transitions, :reboot, :running ).should be_true
+      includes_transition( instance_state.transitions, :stop, :terminated ).should be_true
     end
   end
 
+  def includes_transition( transitions, action, to )
+    found = transitions.find{|e| e.action.to_s == action.to_s && e.to.to_s == to.to_s
}
+    ! found.nil?
+  end
+
 
 end

Modified: incubator/deltacloud/trunk/client-ruby/specs/spec_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/spec_helper.rb?rev=962090&r1=962089&r2=962090&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/spec_helper.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/spec_helper.rb Thu Jul  8 23:22:16 2010
@@ -1,8 +1,16 @@
 require 'yaml'
 require 'fileutils'
 
-API_HOST = 'localhost'
-API_PORT = 3000
+api_host = ENV['API_HOST']
+( api_host = 'localhost' ) if api_host.nil?
+( api_host = 'localhost' ) if api_host == ''
+
+api_port = ENV['API_PORT']
+( api_port = 3000 ) if api_port.nil?
+( api_port = 3000 ) if api_port == ''
+
+API_HOST = api_host
+API_PORT = api_port
 API_PATH = '/api'
 
 API_URL = "http://#{API_HOST}:#{API_PORT}#{API_PATH}"



Mime
View raw message