deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 4/7] Core: Fixed rack-test tests to use Rack::Builder
Date Mon, 10 Sep 2012 09:35:22 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/tests/cimi/collections/cloud_entry_point_test.rb      |    2 +-
 server/tests/cimi/collections/machine_images_test.rb         |    2 +-
 server/tests/cimi/collections/machines_test.rb               |    2 +-
 server/tests/deltacloud/base_collection_test.rb              |    5 -----
 .../tests/deltacloud/collections/buckets_collection_test.rb  |    2 +-
 .../tests/deltacloud/collections/drivers_collection_test.rb  |    2 +-
 .../collections/hardware_profiles_collection_test.rb         |    2 +-
 .../tests/deltacloud/collections/images_collection_test.rb   |    2 +-
 .../collections/instance_states_collection_test.rb           |    2 +-
 .../deltacloud/collections/instances_collection_test.rb      |    2 +-
 server/tests/deltacloud/collections/keys_collection_test.rb  |    2 +-
 server/tests/deltacloud/server_test.rb                       |    2 +-
 server/tests/test_helper.rb                                  |   10 ++++++++++
 13 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/server/tests/cimi/collections/cloud_entry_point_test.rb b/server/tests/cimi/collections/cloud_entry_point_test.rb
index ba9764b..06eb3e9 100644
--- a/server/tests/cimi/collections/cloud_entry_point_test.rb
+++ b/server/tests/cimi/collections/cloud_entry_point_test.rb
@@ -7,7 +7,7 @@ require_relative './common.rb'
 describe CIMI::Collections::CloudEntryPoint do
 
   before do
-    def app; CIMI::API; end
+    def app; run_frontend(:cimi) end
     @collection = CIMI::Collections.collection(:cloudEntryPoint)
   end
 
diff --git a/server/tests/cimi/collections/machine_images_test.rb b/server/tests/cimi/collections/machine_images_test.rb
index 38fa0c4..d65212d 100644
--- a/server/tests/cimi/collections/machine_images_test.rb
+++ b/server/tests/cimi/collections/machine_images_test.rb
@@ -6,7 +6,7 @@ require_relative './common.rb'
 describe CIMI::Collections::MachineImages do
 
   before do
-    def app; CIMI::API; end
+    def app; run_frontend(:cimi) end
     authorize 'mockuser', 'mockpassword'
     @collection = CIMI::Collections.collection(:machine_images)
   end
diff --git a/server/tests/cimi/collections/machines_test.rb b/server/tests/cimi/collections/machines_test.rb
index 77b319f..8d891c5 100644
--- a/server/tests/cimi/collections/machines_test.rb
+++ b/server/tests/cimi/collections/machines_test.rb
@@ -6,7 +6,7 @@ require_relative './common.rb'
 describe CIMI::Collections::Machines do
 
   before do
-    def app; CIMI::API; end
+    def app; run_frontend(:cimi) end
     authorize 'mockuser', 'mockpassword'
     @collection = CIMI::Collections.collection(:machines)
   end
diff --git a/server/tests/deltacloud/base_collection_test.rb b/server/tests/deltacloud/base_collection_test.rb
index 65e2363..661862e 100644
--- a/server/tests/deltacloud/base_collection_test.rb
+++ b/server/tests/deltacloud/base_collection_test.rb
@@ -22,9 +22,4 @@ describe Deltacloud::Collections::Base do
     @base.version.must_equal  Deltacloud.config[:deltacloud].version
   end
 
-  it 'provides helper for routes' do
-    @base.must_respond_to :route_for
-    @base.route_for('/hardware_profiles').must_equal "#{Deltacloud.config[:deltacloud].root_url}/hardware_profiles"
-  end
-
 end
diff --git a/server/tests/deltacloud/collections/buckets_collection_test.rb b/server/tests/deltacloud/collections/buckets_collection_test.rb
index d33b412..80df01e 100644
--- a/server/tests/deltacloud/collections/buckets_collection_test.rb
+++ b/server/tests/deltacloud/collections/buckets_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::Buckets do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     authorize 'mockuser', 'mockpassword'
     @collection = Deltacloud::Collections.collection(:buckets)
   end
diff --git a/server/tests/deltacloud/collections/drivers_collection_test.rb b/server/tests/deltacloud/collections/drivers_collection_test.rb
index 296eba8..6e06a19 100644
--- a/server/tests/deltacloud/collections/drivers_collection_test.rb
+++ b/server/tests/deltacloud/collections/drivers_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::Drivers do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     @collection = Deltacloud::Collections.collection(:drivers)
   end
 
diff --git a/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
index 2f6cf59..9c8df37 100644
--- a/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
+++ b/server/tests/deltacloud/collections/hardware_profiles_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::HardwareProfiles do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     authorize 'mockuser', 'mockpassword'
     @collection = Deltacloud::Collections.collection(:hardware_profiles)
   end
diff --git a/server/tests/deltacloud/collections/images_collection_test.rb b/server/tests/deltacloud/collections/images_collection_test.rb
index ad4f4c0..7b04ba3 100644
--- a/server/tests/deltacloud/collections/images_collection_test.rb
+++ b/server/tests/deltacloud/collections/images_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::Images do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     authorize 'mockuser', 'mockpassword'
     @collection = Deltacloud::Collections.collection(:images)
   end
diff --git a/server/tests/deltacloud/collections/instance_states_collection_test.rb b/server/tests/deltacloud/collections/instance_states_collection_test.rb
index 768a19f..134b664 100644
--- a/server/tests/deltacloud/collections/instance_states_collection_test.rb
+++ b/server/tests/deltacloud/collections/instance_states_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::InstanceStates do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     authorize 'mockuser', 'mockpassword'
     @collection = Deltacloud::Collections.collection(:instance_states)
   end
diff --git a/server/tests/deltacloud/collections/instances_collection_test.rb b/server/tests/deltacloud/collections/instances_collection_test.rb
index 668af4d..79c26ad 100644
--- a/server/tests/deltacloud/collections/instances_collection_test.rb
+++ b/server/tests/deltacloud/collections/instances_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::Instances do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     authorize 'mockuser', 'mockpassword'
     @collection = Deltacloud::Collections.collection(:instances)
   end
diff --git a/server/tests/deltacloud/collections/keys_collection_test.rb b/server/tests/deltacloud/collections/keys_collection_test.rb
index 29b9653..c2e5635 100644
--- a/server/tests/deltacloud/collections/keys_collection_test.rb
+++ b/server/tests/deltacloud/collections/keys_collection_test.rb
@@ -6,7 +6,7 @@ require_relative File.join('..', 'common.rb')
 describe Deltacloud::Collections::Keys do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
     authorize 'mockuser', 'mockpassword'
     @collection = Deltacloud::Collections.collection(:keys)
   end
diff --git a/server/tests/deltacloud/server_test.rb b/server/tests/deltacloud/server_test.rb
index 4a18a37..0f02272 100644
--- a/server/tests/deltacloud/server_test.rb
+++ b/server/tests/deltacloud/server_test.rb
@@ -6,7 +6,7 @@ require_relative 'common.rb'
 describe Deltacloud::API do
 
   before do
-    def app; Deltacloud::API; end
+    def app; run_frontend; end
   end
 
   it 'has the config set property' do
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 57b7fb3..00ebcfa 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -32,6 +32,16 @@ end
 
 include Rack::Test::Methods
 
+def run_frontend(frontend=:deltacloud)
+  Rack::Builder.new {
+    use Rack::MatrixParams
+    map Deltacloud[frontend].root_url do
+      use Rack::MatrixParams
+      run Deltacloud[frontend].klass
+    end
+  }.to_app
+end
+
 def status; last_response.status; end
 def headers; last_response.headers; end
 def response_body; last_response.body; end
-- 
1.7.10.2


Mime
View raw message