2012-02-22 16:47:07 +00:00
|
|
|
require "flowerbox/version"
|
2012-03-08 13:54:27 +00:00
|
|
|
require 'rainbow'
|
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-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-13 17:21:32 +00:00
|
|
|
attr_writer :reporters
|
2012-03-14 17:07:13 +00:00
|
|
|
attr_accessor :port
|
2012-03-13 17:21:32 +00:00
|
|
|
|
|
|
|
def reset!
|
|
|
|
@spec_patterns = nil
|
|
|
|
@spec_files = nil
|
|
|
|
@asset_paths = nil
|
|
|
|
@reporters = nil
|
2012-03-14 17:07:13 +00:00
|
|
|
@port = nil
|
2012-03-13 17:21:32 +00:00
|
|
|
end
|
|
|
|
|
2012-02-22 16:47:07 +00:00
|
|
|
def spec_patterns
|
|
|
|
@spec_patterns ||= []
|
|
|
|
end
|
|
|
|
|
|
|
|
def asset_paths
|
|
|
|
@asset_paths ||= []
|
|
|
|
end
|
|
|
|
|
2012-03-13 17:21:32 +00:00
|
|
|
def reporters
|
|
|
|
@reporters ||= []
|
|
|
|
end
|
|
|
|
|
2012-03-14 17:07:13 +00:00
|
|
|
def additional_files
|
|
|
|
@additional_files ||= []
|
|
|
|
end
|
|
|
|
|
2012-02-22 16:47:07 +00:00
|
|
|
def test_with(what)
|
2012-03-02 18:28:52 +00:00
|
|
|
self.test_environment = Flowerbox::TestEnvironment.for(what)
|
2012-02-22 16:47:07 +00:00
|
|
|
end
|
|
|
|
|
2012-03-02 18:28:52 +00:00
|
|
|
def run_with(*whats)
|
2012-03-03 16:28:03 +00:00
|
|
|
self.runner_environment = whats.flatten.collect { |what| Flowerbox::Runner.for(what.to_s) }
|
2012-02-23 21:12:00 +00:00
|
|
|
end
|
2012-02-22 16:47:07 +00:00
|
|
|
|
2012-03-13 17:21:32 +00:00
|
|
|
def report_with(*whats)
|
|
|
|
self.reporters = whats.flatten.collect { |what| Flowerbox::Reporter.for(what.to_s) }
|
|
|
|
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-16 17:47:52 +00:00
|
|
|
attr_accessor :test_environment, :runner_environment, :bare_coffeescript, :server
|
2012-02-22 16:47:07 +00:00
|
|
|
|
|
|
|
def configure
|
|
|
|
yield self
|
2012-03-02 18:28:52 +00:00
|
|
|
|
|
|
|
if spec_patterns.empty?
|
|
|
|
spec_patterns << "**/*_spec*"
|
|
|
|
spec_patterns << "*/*_spec*"
|
|
|
|
end
|
2012-03-13 17:21:32 +00:00
|
|
|
|
|
|
|
if reporters.empty?
|
|
|
|
reporters << Flowerbox::Reporter.for(:progress)
|
|
|
|
end
|
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-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
|
|
|
|
|
|
|
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
|
|
|
|
puts "Browser already closed."
|
|
|
|
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-02-22 16:47:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|