From 7b1de037f81309b95d723a6c2233649f21050d68 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Wed, 25 Nov 2009 19:47:05 -0800 Subject: [PATCH] Rudimentary rails support --- bin/jasmine | 26 ++++++++++++++++---------- templates/Rakefile | 3 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bin/jasmine b/bin/jasmine index f3a23a4..f098671 100755 --- a/bin/jasmine +++ b/bin/jasmine @@ -26,23 +26,29 @@ if ARGV[0] == 'init' unless File.exist?(expand(dest_spec_helpers, 'spec_helper.js')) File.copy(expand(cwd, 'templates/spec_helper.js'), dest_spec_helpers) - end + end unless File.exist?(expand(dest_spec_helpers, 'jasmine_helper.rb')) File.copy(expand(cwd, 'templates/jasmine_helper.rb'), dest_spec_helpers) end File.copy(expand(cwd, 'templates/example_spec.js'), dest_spec_javascripts) - if File.exist?(expand(dest_root, 'Rakefile')) - existing_rakefile = expand(dest_root, 'Rakefile') - load existing_rakefile - unless Rake::Task.task_defined?('jasmine') - open(existing_rakefile, 'a') do |f| - f.write(File.read(rakefile_path)) - end - end + rails_tasks_dir = expand(dest_root, 'lib', 'tasks') + if File.exist?(rails_tasks_dir) + File.makedirs('lib/tasks/jasmine') + File.copy(rakefile_path, File.join(rails_tasks_dir, 'jasmine/jasmine.rake')) else - File.copy(rakefile_path, dest_root) + if File.exist?(expand(dest_root, 'Rakefile')) + existing_rakefile = expand(dest_root, 'Rakefile') + load existing_rakefile + unless Rake::Task.task_defined?('jasmine') + open(existing_rakefile, 'a') do |f| + f.write(File.read(rakefile_path)) + end + end + else + File.copy(rakefile_path, dest_root) + end end end diff --git a/templates/Rakefile b/templates/Rakefile index ca87506..9dae117 100644 --- a/templates/Rakefile +++ b/templates/Rakefile @@ -10,7 +10,6 @@ namespace :jasmine do require 'spec/rake/spectask' Spec::Rake::SpecTask.new(:ci) do |t| t.spec_opts = ["--color", "--format", "specdoc"] - t.ruby_opts = ["MY_ROOT=foo"] t.verbose = true t.spec_files = [JasmineHelper.meta_spec_path] end @@ -19,7 +18,7 @@ namespace :jasmine do puts " http://localhost:8888/run.html" Jasmine::SimpleServer.start(8888, - File.expand_path(File.join(File.dirname(__FILE__))), + File.expand_path(Dir.pwd), lambda { JasmineHelper.specs }, { :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers, :stylesheets => JasmineHelper.stylesheets