jasmine-coverage 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -26,10 +26,6 @@ To use jasmine-coverage, run the rake task.
26
26
 
27
27
  bundle exec rake jasmine:coverage
28
28
 
29
- Optionally, add a failure level percentage.
30
-
31
- bundle exec rake jasmine:coverage JASMINE_COVERAGE_MINIMUM=75
32
-
33
29
  # Output
34
30
 
35
31
  You will see the tests execute, then a large blob of text, and finally a summary of the test coverage results.
@@ -47,6 +43,18 @@ Files generated will be
47
43
  target/jscoverage/jscoverage.json - The report data
48
44
  target/jscoverage/jscoverage-test-rig.html - The actual page that the tests executed in
49
45
 
46
+ # Configuration
47
+
48
+ You can set a failure level percentage.
49
+
50
+ bundle exec rake jasmine:coverage JASMINE_COVERAGE_MINIMUM=75
51
+
52
+ In addition, as jasmine-coverage has to create a single folder environment for the Javascript sandbox to function correctly, it has to copy
53
+ files into the _target/jscoverage/test_rig_ folder. By default, this is then cleaned up for you if the tests pass. If you'd like to see what files
54
+ it generates regardless, you can specify that in an environment variable.
55
+
56
+ bundle exec rake jasmine:coverage JASMINE_COVERAGE_KEEP_TEST_RIG=true
57
+
50
58
  # How it works
51
59
 
52
60
  First Sprockets is interrogated to get a list of JS files concerned. This way, the right JS files
@@ -1,5 +1,5 @@
1
1
  module Jasmine
2
2
  module Coverage
3
- VERSION = '0.1.5'
3
+ VERSION = '0.1.6'
4
4
  end
5
5
  end
@@ -40,6 +40,7 @@ if env =~ /^(development|test)$/
40
40
 
41
41
  Jasmine::Coverage.resources = files_map
42
42
  Jasmine::Coverage.output_dir = output_dir
43
+ test_rig_folder = "#{Jasmine::Coverage.output_dir}/test_rig"
43
44
 
44
45
  puts "\nCoverage will now be run. Expect a large block of compiled coverage data. This will be processed for you into target/jscoverage.\n\n"
45
46
 
@@ -57,14 +58,21 @@ if env =~ /^(development|test)$/
57
58
  errStr = errStr +"4) The source files are being loaded out of sequence (so global variables are not being declared in order)\n"
58
59
  errStr = errStr +" To check this, run bundle exec jasmine-headless-webkit -l to see the ordering\n"
59
60
  errStr = errStr +"\nIn any case, try running the standard jasmine command to get better errors:\n\nbundle exec jasmine:headless\n"
60
- errStr = errStr +"\nFinally, try opening the testrig in firefox to see the tests run in a browser and get a stacktrace. "
61
+ errStr = errStr +"\nFinally, try opening the test_rig in firefox to see the tests run in a browser and get a stacktrace. "
61
62
  errStr = errStr +"Chrome has strict security settings that make this difficult since it accesses the local filesystem from Javascript (but you can switch the settings off at the command line)\n\n"
62
63
  errStr = errStr +"\n**********************************************************************************************\n"
63
64
  errStr = errStr +"\nThe test rig file needs to load JS directly off disk, which Chrome prevents by default. Your best bet is to open the rig in Firefox.\n"
64
- errStr = errStr +"\nThe file can be found here: #{Jasmine::Coverage.output_dir}/testrig/jscoverage-test-rig.html\n"
65
+ errStr = errStr +"\nThe file can be found here: #{test_rig_folder}/jscoverage-test-rig.html\n"
65
66
  errStr = errStr +"\n**********************************************************************************************\n"
66
67
  fail errStr if status_code == 1
67
68
 
69
+ # Delete the test_rig folder if not required
70
+ if ENV['JASMINE_COVERAGE_KEEP_TEST_RIG']
71
+ p "A copy of the page and files that were used as the jasmine test environment can be found here: #{test_rig_folder}"
72
+ else
73
+ FileUtils.rm_rf test_rig_folder
74
+ end
75
+
68
76
  # Obtain the console log, which includes the coverage report encoded within it
69
77
  contents = File.open("#{output_dir}/rawreport.txt") { |f| f.read }
70
78
  # Get our Base64.
@@ -89,7 +97,6 @@ if env =~ /^(development|test)$/
89
97
  conf = (ENV['JSCOVERAGE_MINIMUM'] || ENV['JASMINE_COVERAGE_MINIMUM'])
90
98
  fail "Coverage Fail: Javascript coverage was less than #{conf}%. It was #{coverage_pc}%." if conf && coverage_pc < conf.to_i
91
99
  end
92
-
93
100
  end
94
101
 
95
102
  def instrument folder, instrumented_sub_dir
@@ -12,16 +12,16 @@ module Jasmine::Headless
12
12
  ret = old_write
13
13
  str = File.open(all_tests_filename, "rb").read
14
14
 
15
- testrigfolder = Jasmine::Coverage.output_dir+"/testrig"
16
- FileUtils.mkdir_p testrigfolder
15
+ test_rigfolder = Jasmine::Coverage.output_dir+"/test_rig"
16
+ FileUtils.mkdir_p test_rigfolder
17
17
 
18
- p "\nCopying all view files and potential javascript fixture folders so the JS has access to the html fixtures.\n"
19
- FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../../spec", "#{testrigfolder}/spec")
20
- FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../../app", "#{testrigfolder}/app")
21
- FileUtils.mkdir_p "#{testrigfolder}/target/fixtures"
22
- FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../fixtures", "#{testrigfolder}/target/fixtures")
23
- FileUtils.mkdir_p "#{testrigfolder}/target/views"
24
- FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../views", "#{testrigfolder}/target/views")
18
+ p "Copying all view files and potential javascript fixture folders so the jasmine-coverage run has access to the html fixtures."
19
+ #FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../../spec", "#{test_rigfolder}/spec")
20
+ #FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../../app", "#{test_rigfolder}/app")
21
+ FileUtils.mkdir_p "#{test_rigfolder}/target/fixtures"
22
+ FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../fixtures", "#{test_rigfolder}/target/fixtures") rescue nil
23
+ FileUtils.mkdir_p "#{test_rigfolder}/target/views"
24
+ FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../views", "#{test_rigfolder}/target/views") rescue nil
25
25
 
26
26
  jss = str.scan(/<script type="text\/javascript" src="(.*)"><\/script>/)
27
27
  jss << str.scan(/<link rel="stylesheet" href="(.*)" type="text\/css" \/>/)
@@ -30,24 +30,24 @@ module Jasmine::Headless
30
30
  jss.each { |s|
31
31
  js = File.basename(s)
32
32
  str.sub!(s, js)
33
- if File.exists?("#{testrigfolder}/#{js}") && js != 'index.js'
34
- s = "\n\n*******************************************************************\n"
33
+ if File.exists?("#{test_rigfolder}/#{js}") && js != 'index.js'
34
+ s = "\n\n*****************************************************************************************************************\n"
35
35
  s = s + "Cannot copy file '#{js}' into jasmine coverage test rig folder.\n"
36
36
  s = s + "There is already another file of that name. You either have two files with the same name (but in different paths)\n"
37
37
  s = s + "or your filename is the same as that from a third party vendor.\n"
38
- s = s + "*******************************************************************\n\n"
38
+ s = s + "The problem stems from the fact that to run all js files from one folder (as is required by a serverless jasmine\n"
39
+ s = s + "test), all your js files must have unique names, even if they are in different folders in your app hierarchy.\n"
40
+ s = s + "*****************************************************************************************************************\n\n"
39
41
  raise s
40
42
  end
41
- FileUtils.cp(s, testrigfolder)
43
+ FileUtils.cp(s, test_rigfolder)
42
44
  }
43
45
 
44
- outfile = "#{testrigfolder}/jscoverage-test-rig.html"
46
+ outfile = "#{test_rigfolder}/jscoverage-test-rig.html"
45
47
  aFile = File.new(outfile, "w")
46
48
  aFile.write(str)
47
49
  aFile.close
48
50
 
49
- puts "A copy of the complete page that was used as the test environment can be found here:"
50
- puts "#{outfile}"
51
51
  ret
52
52
  end
53
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine-coverage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,56 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2013-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
+ type: :runtime
15
16
  name: jasmine-headless-webkit
17
+ prerelease: false
16
18
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
19
  requirements:
19
20
  - - ! '>='
20
21
  - !ruby/object:Gem::Version
21
22
  version: 0.9.0.rc.2
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
23
  none: false
24
+ version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ! '>='
28
27
  - !ruby/object:Gem::Version
29
28
  version: 0.9.0.rc.2
29
+ none: false
30
30
  - !ruby/object:Gem::Dependency
31
+ type: :runtime
31
32
  name: coffee-script-source
33
+ prerelease: false
32
34
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
35
  requirements:
35
36
  - - ! '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
39
  none: false
40
+ version_requirements: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - ! '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
45
+ none: false
46
46
  - !ruby/object:Gem::Dependency
47
+ type: :runtime
47
48
  name: headless
49
+ prerelease: false
48
50
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
51
  requirements:
51
52
  - - ! '>='
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
55
  none: false
56
+ version_requirements: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - ! '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
61
+ none: false
62
62
  description:
63
63
  email:
64
64
  - harry@harrylascelles.com
@@ -80,20 +80,20 @@ rdoc_options: []
80
80
  require_paths:
81
81
  - lib
82
82
  required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
83
  requirements:
85
84
  - - ! '>='
86
85
  - !ruby/object:Gem::Version
87
86
  version: '0'
88
- required_rubygems_version: !ruby/object:Gem::Requirement
89
87
  none: false
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
89
  requirements:
91
90
  - - ! '>='
92
91
  - !ruby/object:Gem::Version
93
92
  version: '0'
93
+ none: false
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 1.8.24
96
+ rubygems_version: 1.8.23
97
97
  signing_key:
98
98
  specification_version: 3
99
99
  summary: A blend of JS unit testing and coverage