Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add coverage support with jscoverage #37

Closed
wants to merge 2 commits into from
@hjdivad

Hi Pivotal team,

This pull request adds (tested) support for generating code coverage reports when jscoverage is installed. It has been tested with the jscoverage-0.5.1 on osx and ubuntu.

Please let me know if you have any comments or concerns.

@dennis1600

Would love to see this integrated. This fork worked perfectly for me.

@matthijsgroen

I would also love to have code coverage measurable through jasmine

@jblotus

+1 for code coverage

@manobi

+1 Awesome

@keke

+1 want it so much

@duncan-bayne

+1 ... pleeeeeeease ...

@averyvery

+1, would be a great addition.

@trevmex

+1

@col
col commented

+1

@tomgi

+1

@mkuklis

Hey Pivotal guys could you please merge this. It's been open for almost a year now and it looks like there are other people interested in this.

@vsanta

+1

@robert-stuttaford

PLUS ONE!

Pivotal? Not much point to using a social coding platform if you're going to ignore us :-)

Pretty please. Do it for the kittens and the unicorns.

Edit: I read the group discussion (http://groups.google.com/group/jasmine-js-dev/browse_thread/thread/a35ad81a1a30931c) and it's been decided that core shouldn't maintain this, so I take back my 'ignore' barb.

Thanks for contributing this, hjdivad! It's brilliant.

@jblotus
@Joe8Bit

+1

@hjdivad hjdivad closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  .gitignore
@@ -9,3 +9,6 @@ bin
*.swp
Gemfile.lock
spec/reports
+/tmp
+/.autotest
+/.rspec
View
6 generators/jasmine/templates/jasmine-example/spec/SpecHelper.js
@@ -2,8 +2,8 @@ beforeEach(function() {
this.addMatchers({
toBePlaying: function(expectedSong) {
var player = this.actual;
- return player.currentlyPlayingSong === expectedSong
- && player.isPlaying;
+ return player.currentlyPlayingSong === expectedSong &&
+ player.isPlaying;
}
- })
+ });
});
View
41 generators/jasmine/templates/spec/javascripts/support/jasmine.yml
@@ -1,3 +1,44 @@
+# coverage
+#
+# Configure support for coverage. Requires jscoverage to be in your PATH.
+#
+# enabled
+#
+# Whether or not coverage is enabled. Can also be enabled by setting
+# JASMINE_COVERAGE_ENABLED in your env.
+#
+# encoding
+#
+# Passed directly to jscoverage
+#
+# temp_dir
+#
+# Where to store instrumented src files.
+#
+# report_dir
+#
+# Where to store coverage reports.
+#
+# skip_paths
+#
+# Passed directly to jscoverage. Paths are relative +src_dir+. Specify
+# paths that should not be instrumented.
+#
+# EXAMPLE:
+#
+# coverage:
+# enabled: true
+# encoding: utf-8
+# temp_dir: tmp
+# report_dir: public/coverage
+#
+coverage:
+ enabled: false
+ encoding: utf-8
+ temp_dir: tmp
+ report_dir: public/coverage
+ skip_paths:
+
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
View
30 lib/generators/jasmine/install/templates/spec/javascripts/helpers/jscoverage.js
@@ -0,0 +1,30 @@
+(function(){
+/* @return an object suitable for consumption by jscoverage.html, i.e. in the
+ * following format;
+ *
+ * { <file> : {
+ * coverage: [<hit_count>, <hit_count>, ...],
+ * source: [<source_line>, <source_line>, ...]
+ * }
+ * }
+ */
+window.jasmine.coverageReport = function() {
+ /* window._$jscoverage is an array with an added source property
+ */
+ var rv = {};
+ for( var file_name in window._$jscoverage ) {
+ var jscov = window._$jscoverage[ file_name ];
+ var file_report = rv[ file_name ] = {
+ coverage: new Array( jscov.length ),
+ source: new Array( jscov.length )
+ };
+ for( var i=0; i < jscov.length; ++i ) {
+ var hit_count = jscov[ i ] !== undefined ? jscov[ i ] : null;
+
+ file_report.coverage[ i ] = hit_count;
+ file_report.source[ i ] = jscov.source[ i ];
+ }
+ }
+ return rv;
+};
+})();
View
41 lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml
@@ -1,3 +1,44 @@
+# coverage
+#
+# Configure support for coverage. Requires jscoverage to be in your PATH.
+#
+# enabled
+#
+# Whether or not coverage is enabled. Can also be enabled by setting
+# JASMINE_COVERAGE_ENABLED in your env.
+#
+# encoding
+#
+# Passed directly to jscoverage
+#
+# temp_dir
+#
+# Where to store instrumented src files.
+#
+# report_dir
+#
+# Where to store coverage reports.
+#
+# skip_paths
+#
+# Passed directly to jscoverage. Paths are relative +src_dir+. Specify
+# paths that should not be instrumented.
+#
+# EXAMPLE:
+#
+# coverage:
+# enabled: true
+# encoding: utf-8
+# temp_dir: tmp
+# report_dir: public/coverage
+#
+coverage:
+ enabled: false
+ encoding: utf-8
+ temp_dir: tmp
+ report_dir: public/coverage
+ skip_paths:
+
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
View
41 lib/generators/jasmine/templates/spec/javascripts/support/jasmine.yml
@@ -1,3 +1,44 @@
+# coverage
+#
+# Configure support for coverage. Requires jscoverage to be in your PATH.
+#
+# enabled
+#
+# Whether or not coverage is enabled. Can also be enabled by setting
+# JASMINE_COVERAGE_ENABLED in your env.
+#
+# encoding
+#
+# Passed directly to jscoverage
+#
+# temp_dir
+#
+# Where to store instrumented src files.
+#
+# report_dir
+#
+# Where to store coverage reports.
+#
+# skip_paths
+#
+# Passed directly to jscoverage. Paths are relative +src_dir+. Specify
+# paths that should not be instrumented.
+#
+# EXAMPLE:
+#
+# coverage:
+# enabled: true
+# encoding: utf-8
+# temp_dir: tmp
+# report_dir: public/coverage
+#
+coverage:
+ enabled: false
+ encoding: utf-8
+ temp_dir: tmp
+ report_dir: public/coverage
+ skip_paths:
+
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
View
87 lib/jasmine/config.rb
@@ -111,7 +111,50 @@ def simple_config_file
File.join(project_root, 'spec/javascripts/support/jasmine.yml')
end
- def src_dir
+ def coverage_config
+ simple_config['coverage'] || { 'enabled' => false }
+ end
+
+ def coverage_enabled?
+ coverage_enabled_in_config = ENV.has_key?("JASMINE_COVERAGE_ENABLED") || coverage_config['enabled']
+ if coverage_enabled_in_config && ! jscoverage_in_path?
+ @warned_about_coverage ||=
+ puts "Warning: jasmine.yml has coverage enabled, but jscoverage was not found using `which jscoverage`."
+ false
+ else
+ coverage_enabled_in_config
+ end
+ end
+
+ def jscoverage_in_path?
+ `which jscoverage` && $?.success?
+ end
+
+ def coverage_encoding
+ coverage_config['encoding'] || 'utf-8'
+ end
+
+ def coverage_skipped_paths
+ coverage_config['skip_paths'] || []
+ end
+
+ def coverage_temp_dir
+ coverage_config['temp_dir'] || 'tmp'
+ end
+
+ def coverage_instrumented_dir
+ File.join coverage_temp_dir, 'javascripts', 'instrumented'
+ end
+
+ def coverage_uninstrumented_dir
+ File.join coverage_temp_dir, 'javascripts', 'uninstrumented'
+ end
+
+ def coverage_report_dir
+ coverage_config['report_dir'] || File.join('public','coverage')
+ end
+
+ def raw_src_dir
if simple_config['src_dir']
File.join(project_root, simple_config['src_dir'])
else
@@ -119,6 +162,14 @@ def src_dir
end
end
+ def src_dir
+ if coverage_enabled?
+ coverage_instrumented_dir
+ else
+ raw_src_dir
+ end
+ end
+
def spec_dir
if simple_config['spec_dir']
File.join(project_root, simple_config['spec_dir'])
@@ -136,11 +187,33 @@ def helpers
end
def src_files
- if simple_config['src_files']
- match_files(src_dir, simple_config['src_files'])
- else
- []
- end
+ files =
+ if simple_config['src_files']
+ match_files(raw_src_dir, simple_config['src_files'])
+ else
+ []
+ end
+ instrument_files! files if coverage_enabled?
+ files
+ end
+
+ def instrument_files!( files )
+ @src_files_instrumented ||= (
+ FileUtils.mkdir_p coverage_uninstrumented_dir
+ files.each do |file|
+ path = File.dirname(file)
+ FileUtils.mkdir_p(File.join(coverage_uninstrumented_dir, path))
+ FileUtils.cp(File.join(raw_src_dir, file), File.join(coverage_uninstrumented_dir, path))
+ end
+ jscoverage_args = ([
+ %Q{--encoding="#{coverage_encoding}"},
+ ] + coverage_skipped_paths.map{|path| %Q{--no-instrument="#{path}"}} + [
+ coverage_uninstrumented_dir,
+ coverage_instrumented_dir,
+ ]).join(" ")
+ system "jscoverage #{jscoverage_args}"
+ true
+ )
end
def spec_files
@@ -159,4 +232,4 @@ def stylesheets
end
end
end
-end
+end
View
5 lib/jasmine/selenium_driver.rb
@@ -38,12 +38,11 @@ def run
end
def eval_js(script)
- result = @driver.execute_script(script)
- JSON.parse("{\"result\":#{result}}")["result"]
+ @driver.execute_script( script )
end
def json_generate(obj)
JSON.generate(obj)
end
end
-end
+end
View
24 lib/jasmine/spec_builder.rb
@@ -1,4 +1,5 @@
require 'enumerator'
+require 'fileutils'
module Jasmine
class SpecBuilder
@@ -20,6 +21,7 @@ def start
end
def stop
+ save_coverage_report! if @config.coverage_enabled?
@runner.stop
end
@@ -74,6 +76,25 @@ def load_results
@spec_results
end
+ def save_coverage_report!
+ FileUtils.mkdir_p @config.coverage_report_dir
+ coverage = eval_js("var result = jasmine.coverageReport(); if (window.Prototype && Object.toJSON) { return Object.toJSON(result) } else { return JSON.stringify(result) }")
+ File.open(File.join(@config.coverage_report_dir, 'jscoverage.json'), 'w') do |file|
+ file.write( json_generate( coverage ))
+ end
+
+ jscoverage_files = %w(
+ jscoverage.css jscoverage-highlight.css jscoverage.html
+ jscoverage-ie.css jscoverage.js jscoverage-throbber.gif).map do |file|
+ File.join(@config.src_dir, file)
+ end
+ FileUtils.cp jscoverage_files, @config.coverage_report_dir
+
+ File.open(File.join(@config.coverage_report_dir, 'jscoverage.js'), 'a') do |jscoverage_js|
+ jscoverage_js.puts "\njscoverage_isReport = true;"
+ end
+ end
+
def wait_for_suites_to_finish_running
puts "Waiting for suite to finish in browser ..."
while !eval_js('return jsApiReporter.finished') do
@@ -152,7 +173,8 @@ def report_spec(spec_id)
private
def eval_js(js)
- @runner.eval_js(js)
+ result = @runner.eval_js(js)
+ JSON.parse("{\"result\":#{result}}")["result"]
end
def json_generate(obj)
View
155 spec/config_spec.rb
@@ -34,6 +34,34 @@
@config.stub!(:project_root).and_return('some_project_root')
@config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml'))
end
+
+ describe "coverage" do
+ before :each do
+ @config.stub!(:project_root).and_return('some_project_root')
+ @config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
+ YAML.stub!(:load).and_return({'src_dir' => nil})
+ end
+
+ it "is disabled" do
+ @config.should_not have_coverage_enabled
+ end
+
+ it "uses tmp" do
+ @config.coverage_temp_dir.should == 'tmp'
+ end
+
+ it "uses public/coverage" do
+ @config.coverage_report_dir.should == File.join('public', 'coverage')
+ end
+
+ it "has utf-8 encoding" do
+ @config.coverage_encoding.should == "utf-8"
+ end
+
+ it "does not skip any paths" do
+ @config.coverage_skipped_paths.should == []
+ end
+ end
end
describe "simple_config" do
@@ -47,6 +75,10 @@
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
end
+ it "should disable coverage support" do
+ @config.should_not have_coverage_enabled
+ end
+
it "should find the source files" do
@config.src_files.should =~ ['public/javascripts/Player.js', 'public/javascripts/Song.js']
end
@@ -127,6 +159,7 @@
Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "file2.ext", "file1.ext"] }
@config.stub!(:simple_config).and_return(fake_config)
+ @config.stub!(:coverage_enabled?).and_return(false)
end
it "src_files" do
@@ -167,6 +200,7 @@
Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
fake_config = Hash.new.stub!(:[]).and_return { |x| ["file1.ext", "!file1.ext", "file2.ext"] }
@config.stub!(:simple_config).and_return(fake_config)
+ @config.stub!(:coverage_enabled?).and_return(false)
end
it "should not contain negated files" do
@@ -224,6 +258,117 @@
'/__spec__/PlayerSpec.js'
]
end
+
+ describe "with coverage enabled" do
+ before :each do
+ @config.stub!(:coverage_config).and_return({
+ 'enabled' => true,
+ 'encoding' => 'utf-8',
+ 'temp_dir' => 'tmp',
+ 'report_dir' => 'public/coverage',
+ })
+ end
+
+ describe "when jscoverage is not in the PATH" do
+ before :each do
+ @config.stub!(:jscoverage_in_path?).and_return(false)
+ end
+
+ it "warns the user" do
+ output = capture_stdout{ @config.src_files }
+ output.should =~ /warn.*jscoverage/i
+ end
+
+ it "disables coverage" do
+ capture_stdout do
+ @config.should_not have_coverage_enabled
+ end
+ end
+ end
+
+ describe "when jscoverage is in the PATH" do
+ before :each do
+ @config.stub!(:jscoverage_in_path?).and_return(true)
+ end
+
+ it "does not warn the user about jscoverage not being in the PATH" do
+ output = capture_stdout{ @config.src_files }
+ output.should_not =~ /warn.*jscoverage/i
+ end
+
+ describe "src_files" do
+ it "invokes jscoverage on the first, and only the first, invocation" do
+ expected_args = %W{
+ jscoverage
+ --encoding="utf-8"
+ #{File.join 'tmp', 'javascripts', 'uninstrumented'}
+ #{File.join 'tmp', 'javascripts', 'instrumented' }
+ }.join(' ')
+ @config.should_receive(:system).exactly(:once).with(expected_args)
+ 3.times{ @config.src_files }
+ end
+
+ it "copies and instruments paths" do
+ instrumented_js_dir = File.join('tmp', 'javascripts', 'instrumented')
+ @config.src_files.each do |src_file|
+ File.join(instrumented_js_dir, src_file).should exist
+ end
+ end
+
+ context "with a non-default encoding" do
+ before :each do
+ @config.stub!(:coverage_encoding){'ascii'}
+ end
+
+ it "invokes jscoverage with the specified encoding" do
+ expected_args = %W{
+ jscoverage
+ --encoding="ascii"
+ #{File.join 'tmp', 'javascripts', 'uninstrumented'}
+ #{File.join 'tmp', 'javascripts', 'instrumented' }
+ }.join(' ')
+ @config.should_receive(:system).with(expected_args)
+ @config.src_files
+ end
+ end
+
+ context "with a specified set of paths to not instrument" do
+ before :each do
+ @config.stub!(:coverage_skipped_paths){["path1", "path2"]}
+ end
+
+ it "invokes jscoverage with --no-instrument" do
+ expected_args = %W{
+ jscoverage
+ --encoding="utf-8"
+ --no-instrument="path1"
+ --no-instrument="path2"
+ #{File.join 'tmp', 'javascripts', 'uninstrumented'}
+ #{File.join 'tmp', 'javascripts', 'instrumented' }
+ }.join(' ')
+ @config.should_receive(:system).with(expected_args)
+ @config.src_files
+ end
+ end
+ end
+
+ describe "src_dir" do
+ before :each do
+ @config.unstub! :src_dir
+ end
+
+ it "returns coverage_instrumented_dir" do
+ @config.src_dir.should == File.join('tmp', 'javascripts', 'instrumented')
+ end
+ end
+
+ describe "raw_src_dir" do
+ it "returns the src directory" do
+ File.absolute_path(@config.src_dir).should == File.absolute_path(@project_dir)
+ end
+ end
+ end
+ end
end
end
@@ -232,6 +377,7 @@ def stub_env_hash(hash)
ENV.stub!(:[]) do |arg|
hash[arg]
end
+ ENV.stub(:has_key?){|k| hash.has_key? k}
end
describe "browser configuration" do
it "should use firefox by default" do
@@ -304,5 +450,14 @@ def stub_env_hash(hash)
Jasmine::SeleniumDriver.new('firefox', 'http://localhost:8888')
end
end
+
+ describe "coverage support" do
+ it "uses JASMINE_COVERAGE_ENABLED if JASMINE_COVERAGE_ENABLED is set" do
+ stub_env_hash({"JASMINE_COVERAGE_ENABLED" => "true" })
+ config = Jasmine::Config.new
+ config.stub!(:simple_config){ Hash.new }
+ config.should have_coverage_enabled
+ end
+ end
end
end
View
9 spec/fixture/src/src.js
@@ -0,0 +1,9 @@
+Example = {};
+Example.foo = function() {
+ var x = 2;
+ return x * x;
+};
+Example.bar = function() {
+ var y = "hello world";
+ return y;
+};
View
33 spec/jasmine_rails2_spec.rb
@@ -60,22 +60,31 @@
`./script/generate jasmine`
end
- it "should find the Jasmine configuration files" do
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
- File.exists?("spec/javascripts/support/jasmine_runner.rb").should == true
- File.exists?("spec/javascripts/support/jasmine_config.rb").should == true
+ %w(
+ spec/javascripts/helpers/jscoverage.js
+ spec/javascripts/support/jasmine.yml
+ spec/javascripts/support/jasmine_runner.rb
+ spec/javascripts/support/jasmine_config.rb
+ ).each do |file|
+ it "should have the Jasmine configuration file #{file}" do
+ file.should exist
+ end
end
- it "should find the Jasmine example files" do
- File.exists?("public/javascripts/Player.js").should == true
- File.exists?("public/javascripts/Song.js").should == true
+ %w(
+ public/javascripts/Player.js
+ public/javascripts/Song.js
- File.exists?("spec/javascripts/PlayerSpec.js").should == true
- File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
+ spec/javascripts/PlayerSpec.js
+ spec/javascripts/helpers/SpecHelper.js
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
- File.exists?("spec/javascripts/support/jasmine_runner.rb").should == true
- File.exists?("spec/javascripts/support/jasmine_config.rb").should == true
+ spec/javascripts/support/jasmine.yml
+ spec/javascripts/support/jasmine_runner.rb
+ spec/javascripts/support/jasmine_config.rb
+ ).each do |file|
+ it "should have the Jasmine example file #{file}" do
+ file.should exist
+ end
end
it "should show jasmine rake task" do
View
17 spec/jasmine_rails3_spec.rb
@@ -44,13 +44,20 @@
@output = `rails g jasmine:install`
end
- it "should have the Jasmine config files" do
+ it "should create the Jasmine config files" do
@output.should include("create")
+ end
- File.exists?("spec/javascripts/helpers/.gitkeep").should == true
- File.exists?("spec/javascripts/support/jasmine.yml").should == true
- File.exists?("spec/javascripts/support/jasmine_runner.rb").should == true
- File.exists?("spec/javascripts/support/jasmine_config.rb").should == true
+ %w(
+ spec/javascripts/helpers/.gitkeep
+ spec/javascripts/helpers/jscoverage.js
+ spec/javascripts/support/jasmine.yml
+ spec/javascripts/support/jasmine_runner.rb
+ spec/javascripts/support/jasmine_config.rb
+ ).each do |file|
+ it "should have the Jasmine config file #{file}" do
+ file.should exist
+ end
end
end
View
8 spec/jasmine_self_test_config.rb
@@ -5,11 +5,11 @@ def project_root
File.expand_path(File.join(File.dirname(__FILE__), ".."))
end
- def src_dir
- File.join(project_root, 'src')
+ def raw_src_dir
+ File.join(project_root, 'spec', 'fixture', 'src')
end
def spec_dir
- File.join(project_root, 'jasmine/spec')
+ File.join(project_root, 'jasmine', 'spec')
end
-end
+end
View
93 spec/jasmine_spec_builder_spec.rb
@@ -0,0 +1,93 @@
+require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
+require 'jasmine_self_test_config'
+require 'fileutils'
+
+describe Jasmine::SpecBuilder do
+ let :run_jasmine_tests do
+ spec_builder = Jasmine::SpecBuilder.new( jasmine_config )
+ spec_builder.start
+ spec_builder.wait_for_suites_to_finish_running
+ spec_builder.stop
+ end
+ let(:report_dir){File.join(File.dirname(__FILE__), '..', 'tmp', 'reports')}
+
+ context "coverage is not enabled" do
+ let :jasmine_config do
+ JasmineSelfTestConfig.new
+ end
+
+ it "does not create +report_dir+" do
+ run_jasmine_tests
+ report_dir.should_not exist
+ end
+ end
+
+ context "coverage is enabled" do
+ let :jasmine_config do
+ config = JasmineSelfTestConfig.new
+ class << config
+ def coverage_config
+ {
+ 'enabled' => true,
+ 'encoding' => 'utf-8',
+ 'temp_dir' => File.join('tmp', 'src'),
+ 'report_dir' => File.join('tmp','reports'),
+ }
+ end
+
+ def simple_config
+ {
+ 'src_files' => ['**/*.js'],
+ 'helpers' => ['support/helpers/**/*.js'],
+ }
+ end
+ end
+ config
+ end
+ let(:helper_dir){File.join(jasmine_config.spec_dir, 'support', 'helpers')}
+ let(:jscoverage_js) do
+ File.join(File.dirname(__FILE__),'..','lib','generators','jasmine','install','templates','spec','javascripts','helpers','jscoverage.js')
+ end
+
+ # Helpers are relative to spec_dir, so jasmine won't serve them out of here
+ before :each do
+ FileUtils.mkdir_p helper_dir
+ FileUtils.cp jscoverage_js, helper_dir
+ FileUtils.rm_rf File.join(File.dirname(__FILE__), '..', 'tmp')
+ end
+
+ after :each do
+ # Don't leave the submodule dirty after a test run
+ FileUtils.rm File.join(helper_dir, File.basename(jscoverage_js))
+ # Clean up tmp
+ FileUtils.rm_rf File.join(File.dirname(__FILE__), '..', 'tmp')
+ end
+
+ it "copies the jscoverage reports to +report_dir+" do
+ run_jasmine_tests
+
+ report_dir.should exist
+ %w( jscoverage.css jscoverage-highlight.css jscoverage.html
+ jscoverage-ie.css jscoverage.js jscoverage-throbber.gif ).each do |jscoverage_file|
+ File.join(report_dir, jscoverage_file).should exist
+ end
+ end
+
+ it "computes and saves jscoverage.json" do
+ run_jasmine_tests
+ json_file = File.join(report_dir, 'jscoverage.json')
+ json_file.should exist
+ json = JSON.parse( File.read( json_file ))
+ json.keys.should == ['src.js']
+ json['src.js']['coverage'].should be_a Array
+ json['src.js']['source'].should be_a Array
+ end
+
+ it "appends jscoverage_isReport = true to jscoverage.js" do
+ run_jasmine_tests
+ jscoverage_file = File.join(report_dir, 'jscoverage.js')
+ jscoverage_file.should exist
+ File.read(jscoverage_file).should include "jscoverage_isReport = true"
+ end
+ end
+end
View
11 spec/spec_helper.rb
@@ -63,3 +63,14 @@ def capture_stdout
$stdout = STDOUT
end
end
+
+
+RSpec::Matchers.define :have_coverage_enabled do
+ match{|actual| actual.coverage_enabled? }
+end
+RSpec::Matchers.define :start_with do |prefix|
+ match{|string| string.start_with? prefix }
+end
+RSpec::Matchers.define :exist do
+ match{|path| File.exists? path }
+end
Something went wrong with that request. Please try again.