2012-02-22 16:47:07 +00:00
|
|
|
require "flowerbox/version"
|
2012-03-08 13:54:27 +00:00
|
|
|
require 'rainbow'
|
2012-03-20 14:53:20 +00:00
|
|
|
require 'forwardable'
|
2012-02-22 16:47:07 +00:00
|
|
|
|
|
|
|
module Flowerbox
|
2012-03-16 17:47:52 +00:00
|
|
|
require 'flowerbox/core_ext/module'
|
2012-03-02 18:28:52 +00:00
|
|
|
|
2012-03-16 17:47:52 +00:00
|
|
|
require 'flowerbox/runner'
|
2012-02-29 19:23:56 +00:00
|
|
|
|
2012-03-16 17:47:52 +00:00
|
|
|
require 'flowerbox/run/base'
|
|
|
|
require 'flowerbox/run/test'
|
|
|
|
require 'flowerbox/run/debug'
|
2012-03-13 17:21:32 +00:00
|
|
|
|
2012-03-16 17:47:52 +00:00
|
|
|
require 'flowerbox/test_environment'
|
|
|
|
require 'flowerbox/result'
|
|
|
|
require 'flowerbox/result_set'
|
|
|
|
require 'flowerbox/gathered_result'
|
2012-03-02 20:04:41 +00:00
|
|
|
|
2012-03-16 17:47:52 +00:00
|
|
|
require 'flowerbox/reporter'
|
2012-03-20 14:53:20 +00:00
|
|
|
require 'flowerbox/configuration'
|
2012-03-16 15:27:58 +00:00
|
|
|
|
2012-03-17 19:03:33 +00:00
|
|
|
if defined?(Rails::Engine)
|
|
|
|
require 'flowerbox/rails/engine'
|
|
|
|
end
|
|
|
|
|
2012-03-19 15:11:29 +00:00
|
|
|
CACHE_DIR = 'tmp/sprockets'
|
2012-03-17 19:03:33 +00:00
|
|
|
|
2012-02-22 16:47:07 +00:00
|
|
|
class << self
|
2012-03-24 14:17:33 +00:00
|
|
|
attr_writer :quiet
|
2012-03-26 15:59:37 +00:00
|
|
|
attr_accessor :server
|
2012-03-24 14:17:33 +00:00
|
|
|
|
2012-03-13 17:21:32 +00:00
|
|
|
def reset!
|
2012-03-20 14:53:20 +00:00
|
|
|
@configuration = nil
|
2012-02-22 16:47:07 +00:00
|
|
|
end
|
|
|
|
|
2012-03-20 14:53:20 +00:00
|
|
|
def configuration
|
|
|
|
@configuration ||= Flowerbox::Configuration.new
|
2012-03-13 17:21:32 +00:00
|
|
|
end
|
|
|
|
|
2012-02-23 21:12:00 +00:00
|
|
|
def path
|
|
|
|
Pathname(File.expand_path('../..', __FILE__))
|
2012-02-22 16:47:07 +00:00
|
|
|
end
|
|
|
|
|
2012-03-20 14:53:20 +00:00
|
|
|
def configure(&block)
|
|
|
|
configuration.configure(&block)
|
2012-03-02 18:28:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def bare_coffeescript
|
|
|
|
@bare_coffeescript ||= true
|
|
|
|
end
|
|
|
|
|
2012-03-14 17:07:13 +00:00
|
|
|
def debug(dir, options = {})
|
2012-03-14 23:53:04 +00:00
|
|
|
Flowerbox::Run::Debug.execute(dir, options)
|
2012-03-14 17:07:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run(dir, options = {})
|
2012-03-24 14:17:33 +00:00
|
|
|
Flowerbox.quiet = options[:quiet]
|
|
|
|
|
2012-03-14 23:53:04 +00:00
|
|
|
Flowerbox::Run::Test.execute(dir, options)
|
2012-02-22 16:47:07 +00:00
|
|
|
end
|
2012-03-15 18:20:07 +00:00
|
|
|
|
2012-03-24 14:17:33 +00:00
|
|
|
def quiet?
|
|
|
|
@quiet == true
|
|
|
|
end
|
|
|
|
|
|
|
|
def notify(msg)
|
|
|
|
if !Flowerbox.quiet?
|
|
|
|
puts msg
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-03-15 18:20:07 +00:00
|
|
|
def browsers
|
|
|
|
@browsers ||= {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def cleanup!
|
2012-03-15 20:07:43 +00:00
|
|
|
browsers.values.each do |browser|
|
|
|
|
begin
|
|
|
|
browser.close
|
|
|
|
rescue Errno::ECONNREFUSED => e
|
2012-03-21 21:36:17 +00:00
|
|
|
puts "Browser already closed.".foreground(:yellow)
|
|
|
|
rescue ::Selenium::WebDriver::Error::UnknownError => e
|
|
|
|
puts "Unknown browser error, pushing past it to close...".foreground(:yellow)
|
2012-03-15 20:07:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-03-15 18:20:07 +00:00
|
|
|
@browsers = {}
|
|
|
|
end
|
2012-03-17 19:03:33 +00:00
|
|
|
|
|
|
|
def transplant(dir)
|
|
|
|
Flowerbox::TestEnvironment.transplantable_environments.each do |env|
|
|
|
|
break if env.transplant(dir)
|
|
|
|
end
|
|
|
|
end
|
2012-03-19 15:11:29 +00:00
|
|
|
|
|
|
|
def cache_dir
|
|
|
|
File.join(CACHE_DIR, Flowerbox.test_environment.name)
|
|
|
|
end
|
2012-03-20 14:53:20 +00:00
|
|
|
|
|
|
|
def method_missing(method, *args)
|
|
|
|
if configuration.respond_to?(method)
|
|
|
|
configuration.send(method, *args)
|
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
2012-02-22 16:47:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|