Class: Jasmine::Headless::FilesList

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/jasmine_headless_coverage_patches.rb

Instance Method Summary collapse

Instance Method Details

#old_sprockets_environmentObject



100
# File 'lib/tasks/jasmine_headless_coverage_patches.rb', line 100

alias old_sprockets_environment :sprockets_environment

#old_to_htmlObject



69
# File 'lib/tasks/jasmine_headless_coverage_patches.rb', line 69

alias old_to_html :to_html

#sprockets_environmentObject



102
103
104
105
106
107
108
# 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

#to_html(files) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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