-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proof of concept coverage implementation
- Loading branch information
A. Speller
committed
Sep 14, 2012
1 parent
296d1eb
commit e4c15bc
Showing
7 changed files
with
244 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ gem 'yard' | |
gem 'redcarpet' | ||
gem 'pry' | ||
gem 'yajl-ruby' | ||
gem 'tilt' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding: utf-8 | ||
require 'tilt' | ||
class JasmineCoverage < Tilt::Template | ||
def prepare | ||
end | ||
|
||
def evaluate(context, locals) | ||
return data unless file.include?(Rails.root.to_s) | ||
return data unless file.include?(Rails.root.join('app', 'assets').to_s) | ||
filename = File.basename(file, '.coffee') | ||
puts "Generating jscoverage instrumented file for #{file.gsub(Rails.root.to_s, '')}" | ||
Dir.mktmpdir do |path| | ||
Dir.mkdir File.join(path, 'in') | ||
File.write File.join(path, 'in', filename), data | ||
`jscoverage --encoding=UTF-8 #{path}/in #{path}/out` | ||
raise "Could not genrate jscoverage instrumented file for #{file}" unless $?.success? | ||
File.read File.join(path, 'out', filename) | ||
end | ||
end | ||
end | ||
|
||
if ENV['JSCOVERAGE'] == 'true' and defined?(Rails) | ||
class GuardJasmineCoverageEngine < Rails::Engine | ||
config.after_initialize do |app| | ||
app.assets.register_postprocessor 'application/javascript', JasmineCoverage | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters