jasmine/lib/jasmine-ruby/jasmine_helper.rb

55 lines
1.1 KiB
Ruby
Raw Normal View History

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
def self.spec_files
2009-10-11 00:44:59 +00:00
Dir.glob(File.join(jasmine_spec_dir, "**/*[Ss]pec.js"))
end
def self.specs
spec_files.collect {|f| f.sub(jasmine_spec_dir, "/spec")}
2009-10-11 00:44:59 +00:00
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
2009-10-11 00:44:59 +00:00
def self.dir_mappings
{
"/spec" => jasmine_spec_dir,
"/lib" => jasmine_lib_dir
}
end
end