flowerbox/lib/flowerbox.rb

95 lines
1.9 KiB
Ruby
Raw Normal View History

2012-02-22 16:47:07 +00:00
require "flowerbox/version"
2012-03-08 13:54:27 +00:00
require 'rainbow'
require 'forwardable'
2012-02-22 16:47:07 +00:00
module Flowerbox
require 'flowerbox/core_ext/module'
2012-03-02 18:28:52 +00:00
require 'flowerbox/runner'
require 'flowerbox/run/base'
require 'flowerbox/run/test'
require 'flowerbox/run/debug'
2012-03-13 17:21:32 +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
require 'flowerbox/reporter'
require 'flowerbox/configuration'
if defined?(Rails::Engine)
require 'flowerbox/rails/engine'
end
2012-03-19 15:11:29 +00:00
CACHE_DIR = 'tmp/sprockets'
2012-02-22 16:47:07 +00:00
class << self
2012-03-13 17:21:32 +00:00
def reset!
@configuration = nil
2012-02-22 16:47:07 +00:00
end
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
def configure(&block)
configuration.configure(&block)
2012-03-02 18:28:52 +00:00
end
def bare_coffeescript
@bare_coffeescript ||= true
end
def debug(dir, options = {})
2012-03-14 23:53:04 +00:00
Flowerbox::Run::Debug.execute(dir, options)
end
def run(dir, options = {})
2012-03-14 23:53:04 +00:00
Flowerbox::Run::Test.execute(dir, options)
2012-02-22 16:47:07 +00:00
end
def browsers
@browsers ||= {}
end
def cleanup!
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)
end
end
@browsers = {}
end
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
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