2011-10-31 23:04:02 +00:00
|
|
|
POLTERGEIST_ROOT = File.expand_path('../..', __FILE__)
|
|
|
|
$:.unshift(POLTERGEIST_ROOT + '/lib')
|
2011-10-27 23:34:14 +01:00
|
|
|
|
|
|
|
require 'bundler/setup'
|
|
|
|
|
|
|
|
require 'rspec'
|
|
|
|
require 'capybara/poltergeist'
|
|
|
|
|
|
|
|
require 'support/test_app'
|
2011-10-30 18:22:44 +00:00
|
|
|
require 'support/spec_logger'
|
2011-10-27 23:34:14 +01:00
|
|
|
|
|
|
|
Capybara.default_wait_time = 0 # less timeout so tests run faster
|
|
|
|
|
|
|
|
alias :running :lambda
|
|
|
|
|
2011-10-30 18:22:44 +00:00
|
|
|
logger = SpecLogger.new
|
|
|
|
|
|
|
|
Capybara.register_driver :poltergeist do |app|
|
2012-01-11 23:32:17 +00:00
|
|
|
Capybara::Poltergeist::Driver.new(app, :logger => logger)
|
2011-10-27 23:34:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
module TestSessions
|
|
|
|
Poltergeist = Capybara::Session.new(:poltergeist, TestApp)
|
|
|
|
end
|
2011-10-30 18:22:44 +00:00
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
config.before do
|
|
|
|
Capybara.configure do |config|
|
|
|
|
config.default_selector = :xpath
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
config.before do
|
|
|
|
logger.reset
|
|
|
|
end
|
|
|
|
|
|
|
|
config.after do |*args|
|
|
|
|
if ENV['DEBUG']
|
|
|
|
puts logger.messages
|
|
|
|
elsif ENV['TRAVIS'] && example.exception
|
|
|
|
example.exception.message << "\n\nDebug info:\n" + logger.messages.join("\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|