Module: Cucumber::Blanket
- Defined in:
- lib/cucumber/blanket.rb,
lib/cucumber/blanket/version.rb,
lib/cucumber/blanket/coverage_data.rb
Defined Under Namespace
Classes: CoverageData
Constant Summary collapse
- VERSION =
"0.1.0"
- @@coverage_data =
CoverageData.new
Class Method Summary collapse
- .coverage_data ⇒ Object
-
.extract_from(page, opts = {setup_wait: 0.5, extract_wait: 0.5}) ⇒ Object
Grab code coverage from the frontend Currently this adds >1 second to every scenario, but it’s worth it The waits are lame but here’s what it’s trying to avoid unknown error: You must call blanket.setupCoverage() first.
- .files ⇒ Object
- .percent ⇒ Object
- .reset! ⇒ Object
Class Method Details
.coverage_data ⇒ Object
9 10 11 |
# File 'lib/cucumber/blanket.rb', line 9 def coverage_data @@coverage_data end |
.extract_from(page, opts = {setup_wait: 0.5, extract_wait: 0.5}) ⇒ Object
Grab code coverage from the frontend Currently this adds >1 second to every scenario, but it’s worth it The waits are lame but here’s what it’s trying to avoid
unknown error: You must call blanket.setupCoverage() first.
(Session info: chrome=31.0.1650.63)
(Driver info: chromedriver=2.6.232908,platform=Mac OS X 10.9.1 x86_64) (Selenium::WebDriver::Error::UnknownError)
27 28 29 30 31 32 33 34 35 |
# File 'lib/cucumber/blanket.rb', line 27 def extract_from page, opts={setup_wait: 0.5, extract_wait: 0.5} sleep opts[:setup_wait] # Give blanketJS time to setupCoverage() before we go to stop it page.evaluate_script("blanket.onTestDone();") page.evaluate_script("blanket.onTestsDone();") sleep opts[:extract_wait] # Allow time for blanketJS and the adapter to prepare the report page_data = page.evaluate_script("window.COVERAGE_RESULTS") @@coverage_data.accrue! page_data return page_data end |
.files ⇒ Object
17 18 19 |
# File 'lib/cucumber/blanket.rb', line 17 def files self.coverage_data.files end |
.percent ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cucumber/blanket.rb', line 37 def percent total_lines = 0 covered_lines = 0 self.files.each do |filename, linedata| linedata.compact.each do |cov_stat| if cov_stat > 0 covered_lines += 1 end total_lines += 1 end end if total_lines > 0 return ((covered_lines.to_f / total_lines)*100).round(2) else return 0.0 end end |
.reset! ⇒ Object
13 14 15 |
# File 'lib/cucumber/blanket.rb', line 13 def reset! @@coverage_data = CoverageData.new end |