lib/js_test_driver/config.rb in js-test-driver-rails-0.3.4 vs lib/js_test_driver/config.rb in js-test-driver-rails-0.4.0
- old
+ new
@@ -57,16 +57,33 @@
# Includes the bundled with the gem jasmine js file and an adapter for jasmine
#
# There's no hacks or modifications here, so this method is just for the users convenience
def enable_jasmine
- this_directory = File.dirname(__FILE__)
- vendor_directory = File.expand_path(File.join('..', '..', 'vendor'), this_directory)
includes File.join(vendor_directory, "jasmine.js")
includes File.join(vendor_directory, "JasmineAdapter.js")
end
+ # Adds a JsTestDriver plugin for measuring coverage to the configuration
+ def measure_coverage
+ @measure_coverage = true
+ self.plugins << {
+ 'name' => 'coverage',
+ 'jar' => File.join(vendor_directory, 'coverage.jar'),
+ 'module' => 'com.google.jstestdriver.coverage.CoverageModule'
+ }
+ end
+
+ def measure_coverage?
+ !!@measure_coverage
+ end
+
+ # Plugins to include in the config
+ def plugins
+ @plugins ||= []
+ end
+
# config variable which has a regular setter,
# but also can be set by calling the "getter" with an argument
# and if called without an argument the getter will return the passed block
#
# Ex.
@@ -123,10 +140,11 @@
def to_s
hash = {'server' => server, 'basepath' => base_path}
hash['load'] = loaded_files unless loaded_files.empty?
hash['exclude'] = map_paths(excluded_files) unless excluded_files.empty?
+ hash['plugin'] = plugins unless plugins.empty?
return hash.to_yaml
end
def self.parse(string)
config = new
@@ -150,9 +168,14 @@
end
end
end
private
+
+ def vendor_directory
+ this_directory = File.dirname(__FILE__)
+ return File.expand_path(File.join('..', '..', 'vendor'), this_directory)
+ end
def expand_globs(paths)
with_expanded_paths = paths.map{|path| File.expand_path(path)}
return with_expanded_paths.map{|path| path.include?('*') ? Dir[path] : path}.flatten
end