2009-10-11 00:44:59 +00:00
|
|
|
class JasmineHelper
|
|
|
|
def self.jasmine_lib_dir
|
|
|
|
File.expand_path(File.join(jasmine_root, 'lib'))
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.jasmine
|
|
|
|
['/lib/' + File.basename(Dir.glob("#{JasmineHelper.jasmine_lib_dir}/jasmine*.js").first)] +
|
|
|
|
['/lib/json2.js',
|
|
|
|
'/lib/TrivialReporter.js']
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.jasmine_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
|
2009-10-31 06:56:05 +00:00
|
|
|
if rails_root
|
2009-10-11 00:44:59 +00:00
|
|
|
File.expand_path(File.join(rails_root, "spec", "javascript"))
|
2009-10-31 06:06:00 +00:00
|
|
|
else
|
|
|
|
File.expand_path('spec')
|
2009-10-11 00:44:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-10-15 07:27:46 +00:00
|
|
|
def self.spec_files
|
2009-10-11 00:44:59 +00:00
|
|
|
Dir.glob(File.join(jasmine_spec_dir, "**/*[Ss]pec.js"))
|
|
|
|
end
|
|
|
|
|
2009-10-15 07:27:46 +00:00
|
|
|
def self.specs
|
|
|
|
spec_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")}
|
2009-10-11 00:44:59 +00:00
|
|
|
end
|
|
|
|
|
2009-11-01 05:35:35 +00:00
|
|
|
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
|
|
|
|
|
2009-10-11 00:44:59 +00:00
|
|
|
def self.dir_mappings
|
|
|
|
{
|
|
|
|
"/spec" => jasmine_spec_dir,
|
|
|
|
"/lib" => jasmine_lib_dir
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|