remove jasmine server; use jasmine init to copy (or append) a Rakefile with common jasmine tasks
This commit is contained in:
1
lib/jasmine-ruby.rb
Normal file
1
lib/jasmine-ruby.rb
Normal file
@@ -0,0 +1 @@
|
||||
require 'jasmine-ruby/jasmine_helper'
|
||||
@@ -1,54 +1,47 @@
|
||||
class JasmineHelper
|
||||
def self.jasmine_lib_dir
|
||||
File.expand_path(File.join(jasmine_root, 'lib'))
|
||||
def self.lib_dir
|
||||
File.expand_path(File.join(root, 'lib'))
|
||||
end
|
||||
|
||||
def self.jasmine
|
||||
['/lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first)] +
|
||||
['/lib/' + File.basename(Dir.glob("#{JasmineHelper.lib_dir}/jasmine*.js").first)] +
|
||||
['/lib/json2.js',
|
||||
'/lib/TrivialReporter.js']
|
||||
end
|
||||
|
||||
def self.jasmine_root
|
||||
def self.root
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'jasmine'))
|
||||
end
|
||||
|
||||
def self.rails_root
|
||||
if defined? RAILS_ROOT
|
||||
RAILS_ROOT
|
||||
else
|
||||
ENV['RAILS_ROOT']
|
||||
end
|
||||
end
|
||||
|
||||
def self.jasmine_spec_dir
|
||||
if rails_root
|
||||
File.expand_path(File.join(rails_root, "spec", "javascript"))
|
||||
else
|
||||
File.expand_path('spec')
|
||||
end
|
||||
def self.spec_dir
|
||||
File.expand_path('spec/javascripts')
|
||||
end
|
||||
|
||||
def self.spec_files
|
||||
Dir.glob(File.join(jasmine_spec_dir, "**/*[Ss]pec.js"))
|
||||
Dir.glob(File.join(spec_dir, "**/*[Ss]pec.js"))
|
||||
end
|
||||
|
||||
def self.specs
|
||||
spec_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")}
|
||||
spec_files.collect {|f| f.sub(spec_dir, "/spec")}
|
||||
end
|
||||
|
||||
def self.spec_helpers_files
|
||||
Dir.glob(File.join(jasmine_spec_dir, "helpers/**/*.js"))
|
||||
Dir.glob(File.join(spec_dir, "helpers/**/*.js"))
|
||||
end
|
||||
|
||||
def self.spec_helpers
|
||||
spec_helpers_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")}
|
||||
spec_helpers_files.collect {|f| f.sub(spec_dir, "/spec")}
|
||||
end
|
||||
|
||||
def self.dir_mappings
|
||||
{
|
||||
"/spec" => jasmine_spec_dir,
|
||||
"/lib" => jasmine_lib_dir
|
||||
"/spec" => spec_dir,
|
||||
"/lib" => lib_dir
|
||||
}
|
||||
end
|
||||
|
||||
def self.meta_spec_path
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'jasmine-ruby', 'jasmine_meta_spec.rb'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
22
lib/jasmine-ruby/jasmine_meta_spec.rb
Normal file
22
lib/jasmine-ruby/jasmine_meta_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'rubygems'
|
||||
require "selenium_rc"
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_helper.rb"))
|
||||
require File.expand_path(File.join(JasmineHelper.root, "contrib/ruby/jasmine_spec_builder"))
|
||||
|
||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
|
||||
JasmineHelper.specs,
|
||||
JasmineHelper.dir_mappings)
|
||||
|
||||
spec_builder = Jasmine::SpecBuilder.new(JasmineHelper.spec_files, jasmine_runner)
|
||||
|
||||
should_stop = false
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
config.after(:suite) do
|
||||
spec_builder.stop if should_stop
|
||||
end
|
||||
end
|
||||
|
||||
spec_builder.start
|
||||
should_stop = true
|
||||
spec_builder.declare_suites
|
||||
Reference in New Issue
Block a user