deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 3/3] Core: Moved rack-test helpers to test_helper
Date Thu, 26 Jul 2012 14:20:34 GMT
From: Michal Fojtik <mfojtik@redhat.com>

The rack-test helpers are now shared with EC2
frontend tests. To avoid code duplication test_helper
will be better place for them.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/tests/deltacloud/common.rb |   16 ++--------------
 server/tests/test_helper.rb       |   11 +++++++++++
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/server/tests/deltacloud/common.rb b/server/tests/deltacloud/common.rb
index 728ad57..d2f59e5 100644
--- a/server/tests/deltacloud/common.rb
+++ b/server/tests/deltacloud/common.rb
@@ -1,22 +1,8 @@
-require 'logger'
-require 'rack/test'
-require 'nokogiri'
-
 require_relative File.join('..', '..', 'lib', 'deltacloud_rack.rb')
 
-include Rack::Test::Methods
-
-def status; last_response.status; end
-def headers; last_response.headers; end
-def response_body; last_response.body; end
-def xml; Nokogiri::XML(response_body); end
-def root_url; Deltacloud.config[:deltacloud].root_url; end
-def formats; [ 'application/xml', 'application/json', 'text/html' ]; end
-
 # Set the default driver used for server API tests
 #
 ENV['API_DRIVER'] = 'mock'
-ENV['RACK_ENV']   = 'test'
 
 # Setup Deltacloud::API Sinatra instance
 #
@@ -30,3 +16,5 @@ unless Deltacloud::config[:deltacloud]
 
   Deltacloud.require_frontend!
 end
+
+def root_url; Deltacloud.config[:deltacloud].root_url; end
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 5aed571..72e26d2 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -1,3 +1,6 @@
+require 'logger'
+require 'rack/test'
+require 'nokogiri'
 require 'pp'
 
 ENV['RACK_ENV'] = 'test'
@@ -30,3 +33,11 @@ unless Kernel.respond_to?(:require_relative)
     end
   end
 end
+
+include Rack::Test::Methods
+
+def status; last_response.status; end
+def headers; last_response.headers; end
+def response_body; last_response.body; end
+def xml; Nokogiri::XML(response_body); end
+def formats; [ 'application/xml', 'application/json', 'text/html' ]; end
-- 
1.7.10.2


Mime
View raw message