deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 25/26] SBC: Fixed cucumber scenatios to work with Sinatra::Base
Date Tue, 15 May 2012 15:15:57 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 tests/sbc/step_definitions/common_steps.rb |    2 +
 tests/sbc/support/env.rb                   |   82 ++++++++++++----------------
 2 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/tests/sbc/step_definitions/common_steps.rb b/tests/sbc/step_definitions/common_steps.rb
index a9cf8e4..d5f9c15 100644
--- a/tests/sbc/step_definitions/common_steps.rb
+++ b/tests/sbc/step_definitions/common_steps.rb
@@ -1,3 +1,5 @@
+World(Rack::Test::Methods)
+
 Given /^I enter ([A-Za-z_]+) collection$/ do |collection|
   @current_collection = collection
   @current_collection_url = "/api/%s" % collection.strip
diff --git a/tests/sbc/support/env.rb b/tests/sbc/support/env.rb
index 2ca8cb4..fe27329 100644
--- a/tests/sbc/support/env.rb
+++ b/tests/sbc/support/env.rb
@@ -1,67 +1,53 @@
-SERVER_DIR = File::expand_path(File::join(File::dirname(__FILE__), "../../../server"))
+require 'rubygems'
+require 'nokogiri'
 
+SERVER_DIR = File::expand_path(File::join(File::dirname(__FILE__), "../../../server"))
 $top_srcdir = SERVER_DIR
 $:.unshift File::join($top_srcdir, 'lib')
-
-ENV['API_DRIVER'] = 'sbc'
-
 Dir.chdir(SERVER_DIR)
 
-require 'rubygems'
-require 'nokogiri'
-require 'deltacloud/server'
-require 'rack/test'
-
-Sinatra::Application.set :environment, :test
-Sinatra::Application.set :root, SERVER_DIR
-
-CONFIG = {
-  :username => 'sbc_test_username',
-  :password => 'sbc_test_password'
-}
-
-ENV['RACK_ENV'] = 'test'
+API_VERSION = "9.9.9"
+API_ROOT_URL = "/api"
 
+ENV['API_DRIVER'] = 'sbc'
+ENV.delete('API_VERBOSE')
 
-World do
+load File.join($top_srcdir, 'lib', 'deltacloud', 'server.rb')
 
-  include Rack::Test::Methods
+require 'rack/test'
 
-  module Rack
-    module Test
-      class Session
-        def headers
-          @headers
-        end
-      end
-    end
-    class MockSession
-      def set_last_response(response)
-        @last_response = response
+module Rack
+  module Test
+    class Session
+      def headers
+        @headers
       end
     end
   end
-
-  def app
-    @app = Rack::Builder.new do
-      set :environment => :development
-      set :loggining => true
-      set :raise_errors => true
-      set :show_exceptions => true
-      run Sinatra::Application
+  class MockSession
+    def set_last_response(response)
+      @last_response = response
     end
   end
+end
 
-  def xml
-    Nokogiri::XML(last_response.body)
-  end
-
+CONFIG = {
+  :username => 'mockuser',
+  :password => 'mockpassword'
+}
 
+def output_xml
+  Nokogiri::XML(last_response.body)
+end
 
-  Before do
-    unless @no_header
-      header 'Accept', 'application/xml;q=9'
-    end
-  end
+def xml
+  Nokogiri::XML(last_response.body)
+end
 
+def app
+  Rack::URLMap.new(
+    "/" => Deltacloud::API.new,
+    "/stylesheets" =>  Rack::Directory.new( "public/stylesheets" ),
+    "/javascripts" =>  Rack::Directory.new( "public/javascripts" )
+  )
 end
-- 
1.7.10.1


Mime
View raw message