From 391c42533fb61da61a6d525bcaaf34ab75f16fdc Mon Sep 17 00:00:00 2001 From: ragaskar Date: Fri, 30 Oct 2009 23:06:00 -0700 Subject: [PATCH] added init task --- bin/jasmine | 18 +++++++++++++----- lib/jasmine-ruby/jasmine_helper.rb | 6 +++--- templates/example_spec.js | 11 +++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 templates/example_spec.js diff --git a/bin/jasmine b/bin/jasmine index 78f16c5..780a9d0 100755 --- a/bin/jasmine +++ b/bin/jasmine @@ -1,18 +1,26 @@ #!/usr/bin/env ruby -require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "jasmine-ruby", "jasmine_helper.rb")) +require 'rubygems' +cwd = File.expand_path(File.join(File.dirname(__FILE__), '..')) +p cwd +require File.expand_path(File.join(cwd, "lib", "jasmine-ruby", "jasmine_helper.rb")) +#to load JasmineHelper overrides if ARGV[1] require File.expand_path(File.join(Dir.pwd, ARGV[1])) end if ARGV[0] == 'server' - require 'rubygems' - require File.expand_path(File.join(__FILE__, "../../jasmine/contrib/ruby/jasmine_spec_builder")) - + require File.expand_path(File.join(cwd, "jasmine/contrib/ruby/jasmine_spec_builder")) puts "your tests are here:" puts " http://localhost:8888/run.html" - JASMINE_SPEC_DIR = ARGV[1] || File.join(Dir.pwd, "spec") Jasmine::SimpleServer.start(8888, lambda { JasmineHelper.specs }, JasmineHelper.dir_mappings) +end + +if ARGV[0] == 'init' + require 'ftools' + File.makedirs('spec') + dest_dir = File.expand_path(File.join(Dir.pwd, 'spec')) + File.copy(File.expand_path(File.join(cwd, 'templates/example_spec.js')), dest_dir) end \ No newline at end of file diff --git a/lib/jasmine-ruby/jasmine_helper.rb b/lib/jasmine-ruby/jasmine_helper.rb index e4609ec..a4eafc7 100755 --- a/lib/jasmine-ruby/jasmine_helper.rb +++ b/lib/jasmine-ruby/jasmine_helper.rb @@ -22,10 +22,10 @@ class JasmineHelper end def self.jasmine_spec_dir - if defined? JASMINE_SPEC_DIR - File.expand_path(File.join(JASMINE_SPEC_DIR)) - else + if defined? rails_root File.expand_path(File.join(rails_root, "spec", "javascript")) + else + File.expand_path('spec') end end diff --git a/templates/example_spec.js b/templates/example_spec.js new file mode 100644 index 0000000..494539e --- /dev/null +++ b/templates/example_spec.js @@ -0,0 +1,11 @@ +describe('ExampleSuite', function () { + it('should have a passing test', function() { + expect(true).toEqual(true); + }); + + describe('Nested Describe', function () { + it('should also have a passing test', function () { + expect(true).toEqual(true); + }); + }); +}); \ No newline at end of file