2011-02-18 22:53:06 -05:00
|
|
|
require 'rspec'
|
|
|
|
require 'rspec/autorun'
|
2011-10-06 11:07:20 -04:00
|
|
|
require 'rbconfig'
|
2012-07-08 16:38:19 -04:00
|
|
|
require 'capybara'
|
2011-02-18 22:53:06 -05:00
|
|
|
|
|
|
|
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) }
|
|
|
|
|
2012-07-08 15:17:08 -04:00
|
|
|
require 'capybara/webkit'
|
2012-11-22 10:30:43 -05:00
|
|
|
connection = Capybara::Webkit::Connection.new(:socket_class => TCPSocket)
|
2012-07-08 15:17:08 -04:00
|
|
|
$webkit_browser = Capybara::Webkit::Browser.new(connection)
|
2011-03-11 11:19:59 -05:00
|
|
|
|
2012-07-08 19:09:40 -04:00
|
|
|
if ENV['DEBUG']
|
|
|
|
$webkit_browser.enable_logging
|
|
|
|
end
|
|
|
|
|
2013-02-17 11:19:38 -05:00
|
|
|
require 'capybara/spec/spec_helper'
|
2012-07-08 16:38:19 -04:00
|
|
|
|
2011-04-14 10:16:56 -04:00
|
|
|
Capybara.register_driver :reusable_webkit do |app|
|
2012-07-08 15:17:08 -04:00
|
|
|
Capybara::Webkit::Driver.new(app, :browser => $webkit_browser)
|
2011-04-14 10:16:56 -04:00
|
|
|
end
|
2012-01-27 10:26:05 -05:00
|
|
|
|
2012-11-30 22:12:11 -05:00
|
|
|
RSpec.configure do |c|
|
|
|
|
c.filter_run_excluding :skip_on_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
|
2013-01-03 13:55:55 -05:00
|
|
|
Capybara::SpecHelper.configure(c)
|
2012-11-30 22:12:11 -05:00
|
|
|
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
|