From 7c043eb5d0bc1f7ce9be748fa98f8579d41aca69 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Sat, 31 Oct 2009 22:35:35 -0700 Subject: [PATCH] Automatically roll up any js files in spec/helpers and add them as spec_helpers --- bin/jasmine | 3 ++- jasmine | 2 +- lib/jasmine-ruby/jasmine_helper.rb | 8 ++++++++ spec/jasmine_spec.rb | 3 ++- tasks/jasmine.rake | 5 +++-- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/jasmine b/bin/jasmine index 1068bb6..21c5bb5 100755 --- a/bin/jasmine +++ b/bin/jasmine @@ -14,7 +14,8 @@ if ARGV[0] == 'server' puts " http://localhost:8888/run.html" Jasmine::SimpleServer.start(8888, lambda { JasmineHelper.specs }, - JasmineHelper.dir_mappings) + JasmineHelper.dir_mappings, + :spec_helpers => JasmineHelper.spec_helpers) end if ARGV[0] == 'init' diff --git a/jasmine b/jasmine index f9d7376..8feb285 160000 --- a/jasmine +++ b/jasmine @@ -1 +1 @@ -Subproject commit f9d73761bb0eaf5a38d522c7d5b0557efc693cd1 +Subproject commit 8feb285ca839cb383eb433c5660ab0f98e86704b diff --git a/lib/jasmine-ruby/jasmine_helper.rb b/lib/jasmine-ruby/jasmine_helper.rb index fbca741..772bf13 100755 --- a/lib/jasmine-ruby/jasmine_helper.rb +++ b/lib/jasmine-ruby/jasmine_helper.rb @@ -37,6 +37,14 @@ class JasmineHelper spec_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")} end + def self.spec_helpers_files + Dir.glob(File.join(jasmine_spec_dir, "helpers/**/*.js")) + end + + def self.spec_helpers + spec_helpers_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")} + end + def self.dir_mappings { "/spec" => jasmine_spec_dir, diff --git a/spec/jasmine_spec.rb b/spec/jasmine_spec.rb index 462506c..4d50565 100644 --- a/spec/jasmine_spec.rb +++ b/spec/jasmine_spec.rb @@ -8,7 +8,8 @@ require File.expand_path(File.join(JasmineHelper.jasmine_root, "contrib/ruby/jas jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, JasmineHelper.spec_file_urls, - JasmineHelper.dir_mappings) + JasmineHelper.dir_mappings, + :spec_helpers => JasmineHelper.spec_helpers) spec_builder = Jasmine::SpecBuilder.new(JasmineHelper.raw_spec_files, jasmine_runner) diff --git a/tasks/jasmine.rake b/tasks/jasmine.rake index d16c5ae..ee32de4 100644 --- a/tasks/jasmine.rake +++ b/tasks/jasmine.rake @@ -8,7 +8,8 @@ def start_jasmine_server Jasmine::SimpleServer.start(8888, lambda { JasmineHelper.spec_file_urls }, - JasmineHelper.dir_mappings) + JasmineHelper.dir_mappings, + :spec_helpers => lambda { JasmineHelper.spec_helpers }) end namespace :jasmine do @@ -22,7 +23,7 @@ namespace :jasmine do require "spec" require 'spec/rake/spectask' ENV["RAILS_ROOT"] = RAILS_ROOT - Spec::Rake::SpecTask.new(:lambda_ci) do |t| + Spec::Rake::SpecTask.new(:lambda_ci) do |t| t.spec_opts = ["--color", "--format", "specdoc"] t.spec_files = [File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "jasmine_spec.rb"))] end