From e9212c674361b3e7c8ff968a3eba7df01298fe8a Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 8 Mar 2012 10:14:29 -0500 Subject: [PATCH] more hacking --- bin/flowerbox | 5 ++++- lib/flowerbox.rb | 2 ++ lib/flowerbox/rack.rb | 4 ---- lib/flowerbox/runner/base.rb | 19 ++++++++++++++++++- lib/flowerbox/runner/node.rb | 9 +++++++++ lib/flowerbox/test_environment/jasmine.rb | 4 ++-- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/bin/flowerbox b/bin/flowerbox index 1f8f0ce..0915ce0 100755 --- a/bin/flowerbox +++ b/bin/flowerbox @@ -8,12 +8,14 @@ class Flowerbox::CLI < Thor method_options :pwd => :string method_options :runners => :string method_options :verbose => false - def test(dir) + def test(dir = "spec/javascripts") Dir.chdir(pwd) do exit Flowerbox.run(dir, options) end end + default_task :test + no_tasks do def pwd options[:pwd] || Dir.pwd @@ -26,3 +28,4 @@ class Flowerbox::CLI < Thor end Flowerbox::CLI.start + diff --git a/lib/flowerbox.rb b/lib/flowerbox.rb index 3a7ba2d..551aade 100644 --- a/lib/flowerbox.rb +++ b/lib/flowerbox.rb @@ -82,6 +82,8 @@ module Flowerbox result_set = ResultSet.new Flowerbox.runner_environment.each do |env| + env.ensure_configured! + result_set << env.run(build_sprockets_for(dir), spec_files_for(dir), options) end diff --git a/lib/flowerbox/rack.rb b/lib/flowerbox/rack.rb index 564e841..0da2f82 100644 --- a/lib/flowerbox/rack.rb +++ b/lib/flowerbox/rack.rb @@ -24,10 +24,6 @@ module Flowerbox end empty_post '/results' do - p "made it" - - p data - runner.finish!(data.flatten.first) end diff --git a/lib/flowerbox/runner/base.rb b/lib/flowerbox/runner/base.rb index 3d0885c..271b0b9 100644 --- a/lib/flowerbox/runner/base.rb +++ b/lib/flowerbox/runner/base.rb @@ -26,6 +26,20 @@ module Flowerbox @results end + def configured? + true + end + + def configure + end + + def ensure_configured! + if !configured? + puts "#{console_name} is not configured for this project, configuring now..." + configure + end + end + def type self.class.name.to_s.split('::').last.downcase.to_sym end @@ -42,7 +56,10 @@ module Flowerbox def server return @server if @server - @server = Flowerbox::Delivery::Server.new(:app => Flowerbox::Rack) + server_options = { :app => Flowerbox::Rack } + server_options[:logging] = true if options[:verbose] + + @server = Flowerbox::Delivery::Server.new(server_options) Flowerbox::Rack.runner = self @server diff --git a/lib/flowerbox/runner/node.rb b/lib/flowerbox/runner/node.rb index f06671d..2936722 100644 --- a/lib/flowerbox/runner/node.rb +++ b/lib/flowerbox/runner/node.rb @@ -20,6 +20,15 @@ module Flowerbox :node end + def configured? + File.directory?(File.join(Dir.pwd, 'node_modules/jsdom')) && + File.directory?(File.join(Dir.pwd, 'node_modules/XMLHttpRequest')) + end + + def configure + system %{bash -c "mkdir -p node_modules && npm link jsdom && npm link xmlhttprequest"} + end + def run(sprockets, spec_files, options) super do begin diff --git a/lib/flowerbox/test_environment/jasmine.rb b/lib/flowerbox/test_environment/jasmine.rb index 0ff21ca..e4154d6 100644 --- a/lib/flowerbox/test_environment/jasmine.rb +++ b/lib/flowerbox/test_environment/jasmine.rb @@ -14,8 +14,8 @@ module Flowerbox end def start_for(runner) - @sprockets.add("flowerbox/jasmine") - @sprockets.add("flowerbox/jasmine/#{runner.type}") + @sprockets.add("flowerbox/jasmine.js") + @sprockets.add("flowerbox/jasmine/#{runner.type}.js") runner.spec_files.each { |file| @sprockets.add(file) }