2011-02-18 22:53:06 -05:00
|
|
|
require 'rspec'
|
|
|
|
require 'rspec/autorun'
|
|
|
|
|
|
|
|
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
|
|
|
|
|
|
|
|
$LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
|
|
|
|
|
|
|
|
Dir[File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')].each { |file| require(file) }
|
|
|
|
|
2011-02-26 17:02:00 -05:00
|
|
|
spec_dir = nil
|
|
|
|
$:.detect do |dir|
|
|
|
|
if File.exists? File.join(dir, "capybara.rb")
|
|
|
|
spec_dir = File.expand_path(File.join(dir,"..","spec"))
|
|
|
|
$:.unshift( spec_dir )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
require File.join(spec_dir,"spec_helper")
|
2011-03-11 11:19:59 -05:00
|
|
|
|
|
|
|
require 'capybara/driver/webkit/browser'
|
2011-08-15 12:17:14 -04:00
|
|
|
$webkit_browser = Capybara::Driver::Webkit::Browser.new(:socket_class => TCPSocket, :stdout => nil)
|
2011-03-11 11:19:59 -05:00
|
|
|
|
2011-04-14 10:16:56 -04:00
|
|
|
Capybara.register_driver :reusable_webkit do |app|
|
|
|
|
Capybara::Driver::Webkit.new(app, :browser => $webkit_browser)
|
|
|
|
end
|
2012-01-27 10:26:05 -05:00
|
|
|
|
|
|
|
def with_env_vars(vars)
|
2012-02-15 10:49:22 -05:00
|
|
|
old_env_variables = {}
|
2012-01-27 10:26:05 -05:00
|
|
|
vars.each do |key, value|
|
|
|
|
old_env_variables[key] = ENV[key]
|
|
|
|
ENV[key] = value
|
|
|
|
end
|
|
|
|
|
|
|
|
yield
|
|
|
|
|
|
|
|
old_env_variables.each do |key, value|
|
|
|
|
ENV[key] = value
|
|
|
|
end
|
|
|
|
end
|