deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [35/50] [abbrv] git commit: SBC: Fixed cucumber scenatios to work with Sinatra::Base
Date Tue, 22 May 2012 20:19:37 GMT
SBC: Fixed cucumber scenatios to work with Sinatra::Base


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/99eec574
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/99eec574
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/99eec574

Branch: refs/heads/master
Commit: 99eec574029dcad6d0ac69327e9541f4959d4988
Parents: 5e87117
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Tue May 15 16:02:02 2012 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue May 22 22:17:36 2012 +0200

----------------------------------------------------------------------
 tests/sbc/step_definitions/common_steps.rb |    2 +
 tests/sbc/support/env.rb                   |   82 +++++++++-------------
 2 files changed, 36 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/99eec574/tests/sbc/step_definitions/common_steps.rb
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/99eec574/tests/sbc/support/env.rb
----------------------------------------------------------------------
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


Mime
View raw message