Class: Webr::Jasmine::Reporter::Console
- Inherits:
-
Base
- Object
- Base
- Webr::Jasmine::Reporter::Console
show all
- Defined in:
- lib/webr/jasmine/reporter/console.rb
Instance Method Summary
collapse
Methods inherited from Base
#filter_backtrace, #log, #reportRunnerStarting, #reportSpecStarting, #reportSuiteResults
Constructor Details
#initialize(jasmine) ⇒ Console
Returns a new instance of Console.
3
4
5
6
7
|
# File 'lib/webr/jasmine/reporter/console.rb', line 3
def initialize(jasmine)
super
@fail_count = 0
end
|
Instance Method Details
#render_results(suites_or_specs) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/webr/jasmine/reporter/console.rb', line 32
def render_results(suites_or_specs)
suites_or_specs.each do |suite_or_spec|
render_suite(suite_or_spec) if @jasmine.isSuite(suite_or_spec)
render_spec(suite_or_spec) if @jasmine.isSpec(suite_or_spec)
end
end
|
#render_spec(spec) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/webr/jasmine/reporter/console.rb', line 43
def render_spec(spec)
unless spec.results.passed
puts "\nFailures:" if @fail_count == 0
@fail_count += 1
puts " #{@fail_count}) #{spec.getFullName}"
spaces = " " * (4 + @fail_count.to_s.size)
spec.results.getItems.each do |item|
unless item.passed
backtrace = if error = item['error']
error.respond_to?(:stack) ? error.stack : error
else
item.trace.stack
end
puts spaces + item.to_s
filter_backtrace(backtrace).each_line do |line|
puts spaces + line
end
puts ""
end
end
end
end
|
#render_suite(suite) ⇒ Object
39
40
41
|
# File 'lib/webr/jasmine/reporter/console.rb', line 39
def render_suite(suite)
render_results(suite.children)
end
|
#render_summary(runner) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/webr/jasmine/reporter/console.rb', line 66
def render_summary(runner)
suites = runner.suites
specs = runner.specs
results = runner.results
hours, minutes, seconds, fraction = Date.send(:day_fraction_to_time, @finished_at - @started_at)
time_taken = "%0.8f" % (hours*60*60 + minutes*60 + seconds + fraction.to_f)
puts "Finished in #{time_taken}s"
puts "Examples: #{specs.length}, Failure#{'s' unless results.failedCount == 1}: #{results.failedCount}"
end
|
#reportRunnerResults(runner) ⇒ Object
10
11
12
13
|
# File 'lib/webr/jasmine/reporter/console.rb', line 10
def reportRunnerResults(runner)
super(runner)
summarize(runner)
end
|
#reportSpecResults(spec) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/webr/jasmine/reporter/console.rb', line 15
def reportSpecResults(spec)
super
if spec.results.passed
$stdout.write('.')
else
$stdout.write('F')
end
end
|
#summarize(runner) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/webr/jasmine/reporter/console.rb', line 25
def summarize(runner)
puts "\n"
render_results(runner.topLevelSuites)
puts "\n"
render_summary(runner)
end
|