more hacking

This commit is contained in:
John Bintz 2012-03-08 10:14:29 -05:00
parent fe51eda8a3
commit e9212c6743
6 changed files with 35 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -24,10 +24,6 @@ module Flowerbox
end
empty_post '/results' do
p "made it"
p data
runner.finish!(data.flatten.first)
end

View File

@ -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

View File

@ -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

View File

@ -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) }