Created
May 23, 2012 12:09
-
-
Save nauman/2774873 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV['API_DRIVER'] = 'fgcp' | |
ENV['API_USERNAME'] = 'cert-dir' | |
ENV['API_PASSWORD'] = 'password' | |
load File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'deltacloud_rack.rb') | |
#load File.join(File.dirname(__FILE__), '..', '..', 'common.rb') | |
Deltacloud::configure do |server| | |
server.root_url '/api' | |
server.version '0.5.0' | |
server.klass 'Deltacloud::API' | |
end.require_frontend! | |
require 'minitest/autorun' | |
require 'rack/test' | |
require 'nokogiri' | |
require 'json' | |
require 'pp' | |
require 'vcr' | |
require 'turn' | |
Turn.config.format = :outline | |
=begin | |
#DeltacloudTestCommon::record! | |
VCR.config do |c| | |
c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures') | |
c.stub_with :webmock | |
c.default_cassette_options = { :record => :new_eposides } | |
end | |
class WebMock::Config | |
def net_http_connect_on_start | |
true | |
end | |
end | |
=end | |
module Deltacloud | |
module Test | |
include Rack::Test::Methods | |
def included?(sub) | |
sub.class_eval do | |
before do | |
header 'Accept', 'application/xml' | |
end | |
end | |
end | |
def xml_response | |
Nokogiri::XML(last_response.body) | |
end | |
def auth_as_mock | |
authorize ENV['API_USERNAME'], ENV['API_PASSWORD'] | |
end | |
def collection_url(collection) | |
[Deltacloud[:root_url], collection.to_s].join('/') | |
end | |
def app | |
Rack::Builder.new { | |
map '/' do | |
use Rack::Static, :urls => ["/stylesheets", "/javascripts"], :root => "public" | |
run Rack::Cascade.new([Deltacloud::API]) | |
end | |
} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment