Class: JazzMoney::JasmineRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/jazz_money/jasmine_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(page, jasmine_spec_files, js_includes, observer, html_fixture_dir = 'spec/javascripts/fixtures') ⇒ JasmineRunner

Returns a new instance of JasmineRunner.



5
6
7
8
9
10
11
# File 'lib/jazz_money/jasmine_runner.rb', line 5

def initialize(page, jasmine_spec_files, js_includes, observer, html_fixture_dir = 'spec/javascripts/fixtures')
  @page = page
  @observer = observer
  @js_includes = js_includes
  @jasmine_spec_files = jasmine_spec_files
  @html_fixture_dir = html_fixture_dir
end

Instance Method Details

#startObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/jazz_money/jasmine_runner.rb', line 13

def start
  load_html_fixtures
  load_jasmine
  @page.window['jazzMoneyReporter'] = @observer
  js = <<-JS
  jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
    var messages = [];
    var results = spec.results().getItems();
    for (var i = 0; i < results.length; i++ ) {
      var item = results[i];
      var message = item.message
      var trace = item.trace.stack
      messages.push({message : message, stack_trace : trace})
    }
    this.results_[spec.id] = {
      messages: messages,
      result: spec.results().failedCount > 0 ? "failed" : "passed"
    };
    jazzMoneyReporter.report_spec_results(spec.id, JSON.stringify(this.results_[spec.id]));
  };
  JS
  @page.execute_js(js)
  load_js_includes
  load_jasmine_spec_files
  start_jasmine
end

#waitObject



40
41
42
# File 'lib/jazz_money/jasmine_runner.rb', line 40

def wait
  @page.execute_js("$wait(-2000)")
end