class Jasmine::Headless::FilesList
Public Instance Methods
sprockets_environment()
click to toggle source
# File lib/tasks/jasmine_headless_coverage_patches.rb, line 102 def sprockets_environment return @sprockets_environment if @sprockets_environment old_sprockets_environment # Add the location of our jscoverage.js @sprockets_environment.append_path(File.dirname(__FILE__)) @sprockets_environment end
Also aliased as: old_sprockets_environment
to_html(files)
click to toggle source
# File lib/tasks/jasmine_headless_coverage_patches.rb, line 71 def to_html(files) # Declare our test runner files cov_files = ['/jscoverage.js', '/base64.min.js', '/coverage_output_generator.js'] # Add the original files, remapping to instrumented where necessary tags = [] (old_to_html files).each do |path| files_map = Jasmine::Coverage.resources files_map.keys.each do |folder| path = path.sub(folder, files_map[folder]) # Here we must check the supplied config hasn't pulled in our jscoverage runner file. # If it has, the tests will fire too early, capturing only minimal coverage if cov_files.select { |f| path.include?(f) }.length > 0 fail "Assets defined by jasmine.yml must not include any of #{cov_files}: #{path}" end end tags << path end # Attach the "in context" test runners tags = tags + old_to_html(cov_files.map { |f| File.dirname(__FILE__)+f }) add_coverage_js_config(tags) tags end
Also aliased as: old_to_html
Private Instance Methods
add_coverage_js_config(tags)
click to toggle source
This method injects the config we have defined in Ruby that needs to be present in the JS context
# File lib/tasks/jasmine_headless_coverage_patches.rb, line 113 def add_coverage_js_config(tags) cov_conf = "#{Jasmine::Coverage.output_dir}/coverage_config.js" tags << "<script type=\"text/javascript\" src=\"#{cov_conf}\"></script>" aFile = File.new(cov_conf, "w") aFile.write("var JasmineCoverage = { warnings: #{Jasmine::Coverage.warnings}}") aFile.close end