jasmine-coverage 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  module Jasmine
2
2
  module Coverage
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
5
5
  end
@@ -55,7 +55,13 @@ if env =~ /^(development|test)$/
55
55
  errStr = errStr +"2) The sourcecode has a syntax error (which JSLint should find)\n"
56
56
  errStr = errStr +"3) The source files are being loaded out of sequence (so global variables are not being declared in order)\n"
57
57
  errStr = errStr +" To check this, run bundle exec jasmine-headless-webkit -l to see the ordering\n"
58
- errStr = errStr +"\nIn any case, try running the standard jasmine command to get better errors:\n\nbundle exec jasmine:headless\n\n"
58
+ errStr = errStr +"\nIn any case, try running the standard jasmine command to get better errors:\n\nbundle exec jasmine:headless\n"
59
+ errStr = errStr +"\nFinally, try opening the testrig in firefox to see the tests run in a browser and get a stacktrace. "
60
+ 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"
61
+ errStr = errStr +"\n**********************************************************************************************\n"
62
+ 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"
63
+ errStr = errStr +"\nThe file can be found here: #{Jasmine::Coverage.output_dir}/testrig/jscoverage-test-rig.html\n"
64
+ errStr = errStr +"\n**********************************************************************************************\n"
59
65
  fail errStr if status_code == 1
60
66
 
61
67
  # Obtain the console log, which includes the coverage report encoded within it
@@ -10,10 +10,34 @@ module Jasmine::Headless
10
10
 
11
11
  def write
12
12
  ret = old_write
13
- file = Jasmine::Coverage.output_dir+"/jscoverage-test-rig.html"
14
- FileUtils.cp(all_tests_filename, file)
13
+ str = File.open(all_tests_filename, "rb").read
14
+
15
+ testrigfolder = Jasmine::Coverage.output_dir+"/testrig"
16
+ FileUtils.mkdir_p testrigfolder
17
+
18
+ p "Copying all view files and potential javascript fixture folders so the JS has access to the html fixtures."
19
+ FileUtils.mkdir_p "#{testrigfolder}/target/fixtures"
20
+ FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../../spec", "#{testrigfolder}/spec")
21
+ FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../../app", "#{testrigfolder}/app")
22
+ FileUtils.copy_entry("#{Jasmine::Coverage.output_dir}/../fixtures", "#{testrigfolder}/target/fixtures")
23
+
24
+ jss = str.scan(/<script type="text\/javascript" src="(.*)"><\/script>/)
25
+ jss << str.scan(/<link rel="stylesheet" href="(.*)" type="text\/css" \/>/)
26
+ jss << str.scan(/\.coffee\.js'\] = '(.*)';<\/script>/)
27
+ jss.flatten!
28
+ jss.each { |s|
29
+ js = File.basename(s)
30
+ str.sub!(s, js)
31
+ FileUtils.cp(s, testrigfolder)
32
+ }
33
+
34
+ outfile = "#{testrigfolder}/jscoverage-test-rig.html"
35
+ aFile = File.new(outfile, "w")
36
+ aFile.write(str)
37
+ aFile.close
38
+
15
39
  puts "A copy of the complete page that was used as the test environment can be found here:"
16
- puts "#{file}"
40
+ puts "#{outfile}"
17
41
  ret
18
42
  end
19
43
  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.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-24 00:00:00.000000000 Z
12
+ date: 2012-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jasmine-headless-webkit