Class: Jscov::Bless

Inherits:
Object
  • Object
show all
Defined in:
lib/jscov/bless.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Bless

Returns a new instance of Bless.



3
4
5
# File 'lib/jscov/bless.rb', line 3

def initialize(response)
  @response = response
end

Class Method Details

.js_codeObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/jscov/bless.rb', line 56

def js_code
  <<~JS
    window.addEventListener("unload", __jscov_dumpCoverage)

    function __jscov_dumpCoverage() {
      const cov = window.__coverage__
      if (!cov) { return }

      console.log('__jscov', JSON.stringify(cov))
    }
  JS
end

Instance Method Details

#resultObject



7
8
9
10
11
12
13
# File 'lib/jscov/bless.rb', line 7

def result
  [
    @response[0],
    headers,
    blessed_body,
  ]
end