diff --git a/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee b/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee index df098e8..ef0c1be 100644 --- a/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee +++ b/lib/assets/javascripts/flowerbox/jasmine/reporter.js.coffee @@ -38,6 +38,7 @@ class jasmine.FlowerboxReporter for item in spec.results().items_ if !item.passed_ result.status = Flowerbox.Result.FAILURE + stack = item.trace.stack || [] if stack.constructor != Array stack = stack.split("\n") diff --git a/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee b/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee index 473db0f..ca85b80 100644 --- a/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee +++ b/lib/assets/javascripts/flowerbox/jasmine/selenium.js.coffee @@ -5,11 +5,13 @@ jasmine.Spec.beforeAddMatcherResult().push -> lol.wut catch e if e.stack - file = switch Flowerbox.environment + file = switch Flowerbox.environment.toLowerCase() when 'firefox' e.stack.split("\n")[3] when 'chrome' e.stack.split("\n")[4] + else + 'unknown:0' - @trace = { stack: [ file ] } + @trace = { stack: [ @message, file ] } diff --git a/lib/flowerbox.rb b/lib/flowerbox.rb index f94f5b8..1fa9453 100644 --- a/lib/flowerbox.rb +++ b/lib/flowerbox.rb @@ -2,46 +2,20 @@ require "flowerbox/version" require 'rainbow' module Flowerbox - module CoreExt - autoload :Module, 'flowerbox/core_ext/module' - end + require 'flowerbox/core_ext/module' - autoload :Runner, 'flowerbox/runner' - autoload :Task, 'flowerbox/task' + require 'flowerbox/runner' - module Run - autoload :Base, 'flowerbox/run/base' - autoload :Test, 'flowerbox/run/test' - autoload :Debug, 'flowerbox/run/debug' - end + require 'flowerbox/run/base' + require 'flowerbox/run/test' + require 'flowerbox/run/debug' - module Runner - autoload :Node, 'flowerbox/runner/node' - autoload :Selenium, 'flowerbox/runner/selenium' - autoload :Firefox, 'flowerbox/runner/firefox' - autoload :Chrome, 'flowerbox/runner/chrome' - autoload :Base, 'flowerbox/runner/base' - end + require 'flowerbox/test_environment' + require 'flowerbox/result' + require 'flowerbox/result_set' + require 'flowerbox/gathered_result' - autoload :TestEnvironment, 'flowerbox/test_environment' - - module TestEnvironment - autoload :Base, 'flowerbox/test_environment/base' - autoload :Jasmine, 'flowerbox/test_environment/jasmine' - autoload :Cucumber, 'flowerbox/test_environment/cucumber' - end - - autoload :Rack, 'flowerbox/rack' - - autoload :ResultSet, 'flowerbox/result_set' - autoload :GatheredResult, 'flowerbox/gathered_result' - autoload :Result, 'flowerbox/result' - - autoload :Reporter, 'flowerbox/reporter' - - autoload :Server, 'flowerbox/server' - autoload :UniqueAssetList, 'flowerbox/unique_asset_list' - autoload :SprocketsHandler, 'flowerbox/sprockets_handler' + require 'flowerbox/reporter' class << self attr_writer :reporters @@ -87,7 +61,7 @@ module Flowerbox Pathname(File.expand_path('../..', __FILE__)) end - attr_accessor :test_environment, :runner_environment, :bare_coffeescript + attr_accessor :test_environment, :runner_environment, :bare_coffeescript, :server def configure yield self diff --git a/lib/flowerbox/reporter.rb b/lib/flowerbox/reporter.rb index f6a00c8..3c3a49d 100644 --- a/lib/flowerbox/reporter.rb +++ b/lib/flowerbox/reporter.rb @@ -2,11 +2,12 @@ module Flowerbox module Reporter extend Flowerbox::CoreExt::Module - autoload :Base, 'flowerbox/reporter/base' - autoload :ConsoleBase, 'flowerbox/reporter/console_base' - autoload :Verbose, 'flowerbox/reporter/verbose' - autoload :Progress, 'flowerbox/reporter/progress' - autoload :FileDisplay, 'flowerbox/reporter/file_display' + require 'flowerbox/reporter/file_display' + + require 'flowerbox/reporter/base' + require 'flowerbox/reporter/console_base' + require 'flowerbox/reporter/verbose' + require 'flowerbox/reporter/progress' end end diff --git a/lib/flowerbox/result.rb b/lib/flowerbox/result.rb index cd9588d..4437c4b 100644 --- a/lib/flowerbox/result.rb +++ b/lib/flowerbox/result.rb @@ -10,12 +10,12 @@ module Flowerbox extend Flowerbox::CoreExt::Module end - autoload :Base, 'flowerbox/result/base' - autoload :Exception, 'flowerbox/result/exception' - autoload :Failure, 'flowerbox/result/failure' - autoload :Pending, 'flowerbox/result/pending' - autoload :FailureMessage, 'flowerbox/result/failure_message' - autoload :FileInfo, 'flowerbox/result/file_info' + require 'flowerbox/result/base' + require 'flowerbox/result/exception' + require 'flowerbox/result/failure' + require 'flowerbox/result/pending' + require 'flowerbox/result/failure_message' + require 'flowerbox/result/file_info' class << self def for(test_env, type) diff --git a/lib/flowerbox/result/base.rb b/lib/flowerbox/result/base.rb index 1eaf7e9..b2653f4 100644 --- a/lib/flowerbox/result/base.rb +++ b/lib/flowerbox/result/base.rb @@ -3,6 +3,7 @@ require 'forwardable' module Flowerbox module Result class Base + require 'flowerbox/result/file_info' include Flowerbox::Result::FileInfo extend Forwardable diff --git a/lib/flowerbox/run/base.rb b/lib/flowerbox/run/base.rb index 3f1fea1..fe2e134 100644 --- a/lib/flowerbox/run/base.rb +++ b/lib/flowerbox/run/base.rb @@ -33,6 +33,8 @@ module Flowerbox::Run end def sprockets + require 'flowerbox/sprockets_handler' + Flowerbox::SprocketsHandler.new( :asset_paths => [ Flowerbox.path.join("lib/assets/javascripts"), diff --git a/lib/flowerbox/run/test.rb b/lib/flowerbox/run/test.rb index 3c9954b..21bdd8f 100644 --- a/lib/flowerbox/run/test.rb +++ b/lib/flowerbox/run/test.rb @@ -1,5 +1,7 @@ module Flowerbox::Run class Test < Base + require 'flowerbox/runner/base' + def execute prep! diff --git a/lib/flowerbox/runner.rb b/lib/flowerbox/runner.rb index af69eb0..5506272 100644 --- a/lib/flowerbox/runner.rb +++ b/lib/flowerbox/runner.rb @@ -1,6 +1,12 @@ module Flowerbox module Runner extend Flowerbox::CoreExt::Module + + def self.find_constant(string) + require "flowerbox/runner/#{string}" + + super + end end end diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index aeb8848..8d3b472 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -1,3 +1,5 @@ +require 'thread' + module Flowerbox module Runner class Base @@ -9,6 +11,10 @@ module Flowerbox class RunnerDiedError < StandardError ; end + def self.mutex + @mutex ||= Mutex.new + end + def initialize @results = ResultSet.new @started = false @@ -40,18 +46,20 @@ module Flowerbox end def run(*args) - setup(*args) + self.class.mutex.synchronize do + setup(*args) - @count = 0 - @timer_running = true + @count = 0 + @timer_running = true - puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{console_name}..." + puts "Flowerbox running your #{Flowerbox.test_environment.name} tests on #{console_name}..." - server.start + server.start - yield + yield - server.stop + server.stop + end @results end @@ -100,17 +108,20 @@ module Flowerbox end def server - return @server if @server + require 'flowerbox/rack' + + Flowerbox::Rack.runner = self + Flowerbox::Rack.sprockets = @sprockets + + return Flowerbox.server if Flowerbox.server + + require 'flowerbox/server' server_options = { :app => Flowerbox::Rack } server_options[:logging] = true if options[:verbose_server] server_options[:port] = Flowerbox.port - @server = Flowerbox::Server.new(server_options) - Flowerbox::Rack.runner = self - Flowerbox::Rack.sprockets = @sprockets - - @server + Flowerbox.server = Flowerbox::Server.new(server_options) end def log(message) diff --git a/lib/flowerbox/runner/chrome.rb b/lib/flowerbox/runner/chrome.rb index e681f64..25311bc 100644 --- a/lib/flowerbox/runner/chrome.rb +++ b/lib/flowerbox/runner/chrome.rb @@ -1,3 +1,5 @@ +require 'flowerbox/runner/selenium' + class Flowerbox::Runner::Chrome < Flowerbox::Runner::Selenium def name "Chrome" diff --git a/lib/flowerbox/runner/firefox.rb b/lib/flowerbox/runner/firefox.rb index bff7786..27a49d6 100644 --- a/lib/flowerbox/runner/firefox.rb +++ b/lib/flowerbox/runner/firefox.rb @@ -1,3 +1,5 @@ +require 'flowerbox/runner/selenium' + class Flowerbox::Runner::Firefox < Flowerbox::Runner::Selenium def name "Firefox" diff --git a/lib/flowerbox/runner/node.rb b/lib/flowerbox/runner/node.rb index 92f502b..aa3449b 100644 --- a/lib/flowerbox/runner/node.rb +++ b/lib/flowerbox/runner/node.rb @@ -1,5 +1,6 @@ require 'tempfile' require 'json' +require 'flowerbox/runner/base' module Flowerbox module Runner diff --git a/lib/flowerbox/runner/selenium.rb b/lib/flowerbox/runner/selenium.rb index 6d67203..e97d61d 100644 --- a/lib/flowerbox/runner/selenium.rb +++ b/lib/flowerbox/runner/selenium.rb @@ -1,4 +1,5 @@ require 'selenium-webdriver' +require 'flowerbox/runner/base' module Flowerbox module Runner diff --git a/lib/flowerbox/sprockets_handler.rb b/lib/flowerbox/sprockets_handler.rb index 0666f40..ab03391 100644 --- a/lib/flowerbox/sprockets_handler.rb +++ b/lib/flowerbox/sprockets_handler.rb @@ -18,6 +18,8 @@ module Flowerbox def initialize(options) @options = options + require 'flowerbox/unique_asset_list' + @files = Flowerbox::UniqueAssetList.new end diff --git a/lib/flowerbox/test_environment.rb b/lib/flowerbox/test_environment.rb index 1f56e88..33de4f7 100644 --- a/lib/flowerbox/test_environment.rb +++ b/lib/flowerbox/test_environment.rb @@ -4,6 +4,8 @@ module Flowerbox class << self def for(env) + require "flowerbox/test_environment/#{env}" + find_constant(env).new end end diff --git a/lib/flowerbox/test_environment/cucumber.rb b/lib/flowerbox/test_environment/cucumber.rb index fd98942..8c9df26 100644 --- a/lib/flowerbox/test_environment/cucumber.rb +++ b/lib/flowerbox/test_environment/cucumber.rb @@ -1,3 +1,5 @@ +require 'flowerbox/test_environment/base' + module Flowerbox module TestEnvironment class Cucumber < Base @@ -12,6 +14,8 @@ module Flowerbox def inject_into(sprockets) super + require 'flowerbox/tilt/feature_template' + @sprockets.register_engine('.feature', Flowerbox::Tilt::FeatureTemplate) end @@ -84,9 +88,3 @@ JS end end -module Flowerbox - module Tilt - autoload :FeatureTemplate, 'flowerbox/tilt/feature_template' - end -end - diff --git a/lib/flowerbox/test_environment/jasmine.rb b/lib/flowerbox/test_environment/jasmine.rb index 23b987e..729a83b 100644 --- a/lib/flowerbox/test_environment/jasmine.rb +++ b/lib/flowerbox/test_environment/jasmine.rb @@ -1,3 +1,4 @@ +require 'flowerbox/test_environment/base' require 'jasmine-core' module Flowerbox diff --git a/lib/flowerbox/tilt/feature_template.rb b/lib/flowerbox/tilt/feature_template.rb index d5e734a..b6586bf 100644 --- a/lib/flowerbox/tilt/feature_template.rb +++ b/lib/flowerbox/tilt/feature_template.rb @@ -1,21 +1,23 @@ require 'tilt' -module Flowerbox::Tilt - class FeatureTemplate < Tilt::Template - self.default_mime_type = 'application/javascript' +module Flowerbox + module Tilt + class FeatureTemplate < ::Tilt::Template + self.default_mime_type = 'application/javascript' - def prepare; end + def prepare; end - def evaluate(scope, locals, &block) - <<-JS + def evaluate(scope, locals, &block) + <<-JS Flowerbox.Cucumber.Features = Flowerbox.Cucumber.Features || []; Flowerbox.Cucumber.Features.push("#{escaped_data}"); JS - end + end - def escaped_data - data.gsub("\n", "\\n").gsub('"', '\\"') + def escaped_data + data.gsub("\n", "\\n").gsub('"', '\\"') + end end end end