turnip_formatter 0.6.0.pre.beta.2 → 0.6.0.pre.beta.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Rakefile +3 -2
- data/lib/rspec/core/formatters/turnip_formatter.rb +8 -9
- data/lib/turnip_formatter/ext/turnip/rspec.rb +6 -5
- data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.css +1 -1
- data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.js +0 -0
- data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.scss +1 -1
- data/lib/turnip_formatter/renderer/html/base.rb +4 -4
- data/lib/turnip_formatter/renderer/html/index.rb +83 -0
- data/lib/turnip_formatter/renderer/html/runtime_error.rb +20 -0
- data/lib/turnip_formatter/renderer/html/scenario.rb +20 -0
- data/lib/turnip_formatter/renderer/html/statistics_feature.rb +45 -0
- data/lib/turnip_formatter/renderer/html/statistics_speed.rb +39 -0
- data/lib/turnip_formatter/renderer/html/statistics_tag.rb +53 -0
- data/lib/turnip_formatter/renderer/html/views/index.html.erb +94 -0
- data/lib/turnip_formatter/renderer/html/views/runtime_error.html.erb +20 -0
- data/lib/turnip_formatter/renderer/html/views/scenario.html.erb +23 -0
- data/lib/turnip_formatter/renderer/html/views/statistics_feature.html.erb +24 -0
- data/lib/turnip_formatter/renderer/html/views/statistics_speed.html.erb +24 -0
- data/lib/turnip_formatter/renderer/html/views/statistics_tag.html.erb +24 -0
- data/lib/turnip_formatter/renderer/html.rb +84 -0
- data/lib/turnip_formatter/resource/scenario/base.rb +80 -0
- data/lib/turnip_formatter/resource/scenario/failure.rb +50 -0
- data/lib/turnip_formatter/resource/scenario/pass.rb +10 -0
- data/lib/turnip_formatter/resource/scenario/pending.rb +42 -0
- data/lib/turnip_formatter/version.rb +1 -1
- data/lib/turnip_formatter.rb +8 -4
- data/test/helper.rb +64 -12
- data/test/turnip_formatter/renderer/html/test_index.rb +102 -0
- data/test/turnip_formatter/renderer/html/test_runtime_error.rb +40 -0
- data/test/turnip_formatter/renderer/html/test_statistics_feature.rb +102 -0
- data/test/turnip_formatter/renderer/html/test_statistics_speed.rb +77 -0
- data/test/turnip_formatter/renderer/html/test_statistics_tag.rb +112 -0
- data/test/turnip_formatter/renderer/html/test_step.rb +27 -0
- data/test/turnip_formatter/renderer/test_html.rb +75 -0
- data/test/turnip_formatter/resource/scenario/test_failure.rb +39 -0
- data/test/turnip_formatter/resource/scenario/test_pass.rb +65 -0
- data/test/turnip_formatter/resource/scenario/test_pending.rb +39 -0
- data/turnip_formatter.gemspec +1 -1
- metadata +45 -57
- data/lib/turnip_formatter/printer/index.rb +0 -26
- data/lib/turnip_formatter/printer/runtime_error.rb +0 -36
- data/lib/turnip_formatter/printer/scenario.rb +0 -22
- data/lib/turnip_formatter/printer/tab_feature_statistics.rb +0 -46
- data/lib/turnip_formatter/printer/tab_speed_statistics.rb +0 -35
- data/lib/turnip_formatter/printer/tab_tag_statistics.rb +0 -76
- data/lib/turnip_formatter/printer.rb +0 -29
- data/lib/turnip_formatter/scenario/base.rb +0 -99
- data/lib/turnip_formatter/scenario/failure.rb +0 -44
- data/lib/turnip_formatter/scenario/pass.rb +0 -8
- data/lib/turnip_formatter/scenario/pending.rb +0 -40
- data/lib/turnip_formatter/step.rb +0 -23
- data/lib/turnip_formatter/template/exception.slim +0 -8
- data/lib/turnip_formatter/template/index.slim +0 -86
- data/lib/turnip_formatter/template/runtime_exception.slim +0 -13
- data/lib/turnip_formatter/template/scenario.slim +0 -15
- data/lib/turnip_formatter/template/tab_feature_statistics.slim +0 -18
- data/lib/turnip_formatter/template/tab_speed_statistics.slim +0 -16
- data/lib/turnip_formatter/template/tab_tag_statistics.slim +0 -18
- data/spec/turnip_formatter/printer/index_spec.rb +0 -38
- data/spec/turnip_formatter/printer/scenario_spec.rb +0 -42
- data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +0 -80
- data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +0 -48
- data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +0 -103
- data/spec/turnip_formatter/scenario/base_spec.rb +0 -67
- data/spec/turnip_formatter/scenario/failure_spec.rb +0 -55
- data/spec/turnip_formatter/scenario/pending_spec.rb +0 -51
- data/spec/turnip_formatter/template_spec.rb +0 -119
- data/test/sample.feature +0 -16
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'active_support/core_ext/string/inflections' # String#{demodulize,underscore}
|
2
|
-
require '
|
2
|
+
require 'erb'
|
3
3
|
require 'forwardable'
|
4
4
|
|
5
5
|
module TurnipFormatter
|
@@ -12,8 +12,8 @@ module TurnipFormatter
|
|
12
12
|
|
13
13
|
class << self
|
14
14
|
def view
|
15
|
-
@view ||= ::
|
16
|
-
"#{TEMPLATE_DIRECTORY}/#{resource_name}.html.erb"
|
15
|
+
@view ||= ::ERB.new(
|
16
|
+
File.read("#{TEMPLATE_DIRECTORY}/#{resource_name}.html.erb")
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
@@ -39,7 +39,7 @@ module TurnipFormatter
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def render
|
42
|
-
view.
|
42
|
+
view.result(binding)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'turnip_formatter'
|
2
|
+
require 'turnip_formatter/renderer/html/scenario'
|
3
|
+
require 'turnip_formatter/renderer/html/statistics_feature'
|
4
|
+
require 'turnip_formatter/renderer/html/statistics_tag'
|
5
|
+
require 'turnip_formatter/renderer/html/statistics_speed'
|
6
|
+
|
7
|
+
module TurnipFormatter
|
8
|
+
module Renderer
|
9
|
+
module Html
|
10
|
+
#
|
11
|
+
# @resource [Hash]
|
12
|
+
#
|
13
|
+
# scenarios: [Array<TurnipFormatter:Resource::Scenario::Base>]
|
14
|
+
# failed_count: [Integer]
|
15
|
+
# pending_count: [Integer]
|
16
|
+
# total_time: [Float]
|
17
|
+
#
|
18
|
+
class Index < Base
|
19
|
+
def style_links
|
20
|
+
Html.render_stylesheet_links
|
21
|
+
end
|
22
|
+
|
23
|
+
def style_codes
|
24
|
+
Html.render_stylesheet_codes + Html.render_step_template_stylesheet_codes
|
25
|
+
end
|
26
|
+
|
27
|
+
def script_links
|
28
|
+
Html.render_javascript_links
|
29
|
+
end
|
30
|
+
|
31
|
+
def script_codes
|
32
|
+
Html.render_javascript_codes
|
33
|
+
end
|
34
|
+
|
35
|
+
def title
|
36
|
+
Html.project_name + ' report'
|
37
|
+
end
|
38
|
+
|
39
|
+
def scenarios_html
|
40
|
+
scenarios.map do |s|
|
41
|
+
begin
|
42
|
+
Scenario.new(s).render
|
43
|
+
rescue => e
|
44
|
+
RuntimeError.new([e, s]).render
|
45
|
+
end
|
46
|
+
end.join
|
47
|
+
end
|
48
|
+
|
49
|
+
def statistics_feature_html
|
50
|
+
StatisticsFeature.new(scenarios).render
|
51
|
+
end
|
52
|
+
|
53
|
+
def statistics_tag_html
|
54
|
+
StatisticsTag.new(scenarios).render
|
55
|
+
end
|
56
|
+
|
57
|
+
def statistics_speed_html
|
58
|
+
StatisticsSpeed.new(scenarios).render
|
59
|
+
end
|
60
|
+
|
61
|
+
def result_status
|
62
|
+
str = "#{scenarios.size} Scenario "
|
63
|
+
str += "(#{@resource[:failed_count]} failed #{@resource[:pending_count]} pending)"
|
64
|
+
str
|
65
|
+
end
|
66
|
+
|
67
|
+
def total_time
|
68
|
+
@resource[:total_time].to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
def turnip_version
|
72
|
+
Turnip::VERSION
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def scenarios
|
78
|
+
@resource[:scenarios]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'turnip_formatter/renderer/html/base'
|
2
|
+
|
3
|
+
module TurnipFormatter
|
4
|
+
module Renderer
|
5
|
+
module Html
|
6
|
+
#
|
7
|
+
# @resource [Array<Exception, TurnipFormatter::Resource::Scenario::XXX>]
|
8
|
+
#
|
9
|
+
class RuntimeError < Base
|
10
|
+
def runtime_exception
|
11
|
+
@resource[0]
|
12
|
+
end
|
13
|
+
|
14
|
+
def scenario
|
15
|
+
@resource[1]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'turnip_formatter/renderer/html/step'
|
2
|
+
|
3
|
+
module TurnipFormatter
|
4
|
+
module Renderer
|
5
|
+
module Html
|
6
|
+
#
|
7
|
+
# @resource [TurnipFormatter::Resource::Scenario::Base]
|
8
|
+
#
|
9
|
+
class Scenario < Base
|
10
|
+
delegate :id, :status, :run_time, :tags, :feature_info, :name, :feature
|
11
|
+
|
12
|
+
def steps_html
|
13
|
+
@steps_html ||= @resource.steps.map do |step|
|
14
|
+
Step.new(step).render
|
15
|
+
end.join
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'turnip_formatter/renderer/html/base'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module TurnipFormatter
|
5
|
+
module Renderer
|
6
|
+
module Html
|
7
|
+
#
|
8
|
+
# @resource [Array<TurnipFormatter::Resource::Scenario::XXX>]
|
9
|
+
#
|
10
|
+
class StatisticsFeature < Base
|
11
|
+
def results
|
12
|
+
@results ||= features.map do |name, scenarios|
|
13
|
+
analysis(name, scenarios)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def features
|
20
|
+
@features ||= @resource.group_by { |s| s.feature.name }
|
21
|
+
end
|
22
|
+
|
23
|
+
def analysis(name, scenarios)
|
24
|
+
group = scenarios.group_by { |s| s.status }
|
25
|
+
group.default = []
|
26
|
+
|
27
|
+
info = OpenStruct.new(
|
28
|
+
name: name,
|
29
|
+
scenario_count: scenarios.size,
|
30
|
+
passed_count: group[:passed].size,
|
31
|
+
failed_count: group[:failed].size,
|
32
|
+
pending_count: group[:pending].size,
|
33
|
+
status: :failed
|
34
|
+
)
|
35
|
+
|
36
|
+
if info.failed_count.zero?
|
37
|
+
info.status = info.pending_count.zero? ? :passed : :pending
|
38
|
+
end
|
39
|
+
|
40
|
+
info
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'turnip_formatter/renderer/html/base'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module TurnipFormatter
|
5
|
+
module Renderer
|
6
|
+
module Html
|
7
|
+
#
|
8
|
+
# @resource [Array<TurnipFormatter::Resource::Scenario::XXX>]
|
9
|
+
#
|
10
|
+
class StatisticsSpeed < Base
|
11
|
+
def results
|
12
|
+
@results ||= analysis(scenarios)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
#
|
18
|
+
# Use the successfully steps only
|
19
|
+
#
|
20
|
+
def scenarios
|
21
|
+
@scenarios ||= @resource.select { |s| s.status == :passed }
|
22
|
+
end
|
23
|
+
|
24
|
+
def analysis(scenarios)
|
25
|
+
scenarios.map do |s|
|
26
|
+
OpenStruct.new(
|
27
|
+
{
|
28
|
+
id: s.id,
|
29
|
+
feature_name: s.feature.name,
|
30
|
+
name: s.name,
|
31
|
+
run_time: s.run_time
|
32
|
+
}
|
33
|
+
)
|
34
|
+
end.sort { |a, b| a.run_time <=> b.run_time }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'turnip_formatter/renderer/html/base'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module TurnipFormatter
|
5
|
+
module Renderer
|
6
|
+
module Html
|
7
|
+
#
|
8
|
+
# @resource [Array<TurnipFormatter::Resource::Scenario::XXX>]
|
9
|
+
#
|
10
|
+
class StatisticsTag < Base
|
11
|
+
def results
|
12
|
+
@results ||= tags.map do |name, scenarios|
|
13
|
+
analysis(name, scenarios)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def tags
|
20
|
+
@tags ||= @resource.map do |scenario|
|
21
|
+
if scenario.tags.empty?
|
22
|
+
{ name: 'no_tag', scenario: scenario }
|
23
|
+
else
|
24
|
+
scenario.tags.map do |tag|
|
25
|
+
{ name: '@' + tag, scenario: scenario }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end.flatten.group_by { |s| s[:name] }.sort
|
29
|
+
end
|
30
|
+
|
31
|
+
def analysis(name, scenarios)
|
32
|
+
group = scenarios.group_by { |s| s[:scenario].status }
|
33
|
+
group.default = []
|
34
|
+
|
35
|
+
info = OpenStruct.new(
|
36
|
+
name: name,
|
37
|
+
scenario_count: scenarios.size,
|
38
|
+
passed_count: group[:passed].size,
|
39
|
+
failed_count: group[:failed].size,
|
40
|
+
pending_count: group[:pending].size,
|
41
|
+
status: :failed
|
42
|
+
)
|
43
|
+
|
44
|
+
if info.failed_count.zero?
|
45
|
+
info.status = info.pending_count.zero? ? :passed : :pending
|
46
|
+
end
|
47
|
+
|
48
|
+
info
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<title><%= ERB::Util.h(title) %></title>
|
6
|
+
|
7
|
+
<%= style_links %>
|
8
|
+
<style><%= style_codes %></style>
|
9
|
+
|
10
|
+
<script src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
11
|
+
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
|
12
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.17.0/jquery.tablesorter.min.js"></script>
|
13
|
+
|
14
|
+
<%= script_links %>
|
15
|
+
<script><%= script_codes %></script>
|
16
|
+
</head>
|
17
|
+
|
18
|
+
<body>
|
19
|
+
<header id="report">
|
20
|
+
<div class="container">
|
21
|
+
<div class="page-header">
|
22
|
+
<h1><%= ERB::Util.h(title) %></h1>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<section id="status_display_switch">
|
26
|
+
<label for="passed_check">
|
27
|
+
<input id="passed_check" type="checkbox" /> Passed
|
28
|
+
</label>
|
29
|
+
<label for="failed_check">
|
30
|
+
<input id="failed_check" type="checkbox" checked="checked" /> Failed
|
31
|
+
</label>
|
32
|
+
<label for="pending_check">
|
33
|
+
<input id="pending_check" type="checkbox" /> Pending
|
34
|
+
</label>
|
35
|
+
</section>
|
36
|
+
|
37
|
+
<section id="result">
|
38
|
+
<p><%= result_status %></p>
|
39
|
+
<p>Finished in <%= total_time %> sec</p>
|
40
|
+
</section>
|
41
|
+
</div>
|
42
|
+
</header>
|
43
|
+
|
44
|
+
<div id="main" class="container" role="main">
|
45
|
+
<ul id="statistics" class="nav nav-tabs">
|
46
|
+
<li class="active">
|
47
|
+
<a data-toggle="tab" href="#steps-statistics">Steps</a>
|
48
|
+
</li>
|
49
|
+
<li>
|
50
|
+
<a data-toggle="tab" href="#speed-statistics">Speed Statistics</a>
|
51
|
+
</li>
|
52
|
+
<li>
|
53
|
+
<a data-toggle="tab" href="#feature-statistics">Feature Sttistics</a>
|
54
|
+
</li>
|
55
|
+
<li>
|
56
|
+
<a data-toggle="tab" href="#tag-statistics">Tag Statistics</a>
|
57
|
+
</li>
|
58
|
+
</ul>
|
59
|
+
|
60
|
+
<div class="tab-content">
|
61
|
+
<div id="steps-statistics" class="tab-pane active">
|
62
|
+
<div class="checkbox">
|
63
|
+
<label>
|
64
|
+
<input id="scenario_display_check" type="checkbox" checked="checked" /> Folding
|
65
|
+
</label>
|
66
|
+
</div>
|
67
|
+
|
68
|
+
<div id="scenarios" class="panel-group"><%= scenarios_html %></div>
|
69
|
+
</div>
|
70
|
+
<div id="feature-statistics" class="tab-pane">
|
71
|
+
<h4>The results for the feature:</h4>
|
72
|
+
<%= statistics_feature_html %>
|
73
|
+
</div>
|
74
|
+
<div id="tag-statistics" class="tab-pane">
|
75
|
+
<h4>The results for the tab:</h4>
|
76
|
+
<%= statistics_tag_html %>
|
77
|
+
</div>
|
78
|
+
<div id="speed-statistics" class="tab-pane">
|
79
|
+
<h4>Ranking of running time of each <strong>successfully</strong> scenario:</h4>
|
80
|
+
<%= statistics_speed_html %>
|
81
|
+
</div>
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<footer>
|
86
|
+
<p>Generated by <a href="https://rubygems.org/gems/turnip_formatter">turnip_formatter <%= turnip_version %></a></p>
|
87
|
+
<p>
|
88
|
+
Powered by
|
89
|
+
<a href="http://jquery.com/"> jQuery 1.11.0</a>
|
90
|
+
and
|
91
|
+
<a href="http://mottie.github.io/tablesorter">tablesorter 2.17.0</a>
|
92
|
+
</footer>
|
93
|
+
</body>
|
94
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<section class="exception">
|
2
|
+
<h1>TurnipFormatter Runtime Error</h1>
|
3
|
+
<h2><%= scenario.feature_info %></h2>
|
4
|
+
|
5
|
+
<dl>
|
6
|
+
<dt>Runtime Error</dt>
|
7
|
+
<dd>
|
8
|
+
<pre><%= runtime_exception.to_s %></pre>
|
9
|
+
</dd>
|
10
|
+
|
11
|
+
<dt>Runtime Error Backtrace</dt>
|
12
|
+
<dd>
|
13
|
+
<ol>
|
14
|
+
<% runtime_exception.backtrace.each do |line| %>
|
15
|
+
<li><%= ERB::Util.h(line) %></li>
|
16
|
+
<% end %>
|
17
|
+
</ol>
|
18
|
+
</dd>
|
19
|
+
</dl>
|
20
|
+
</section>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<section class="scenario <%= status %>" id="<%= id %>">
|
2
|
+
<div class="scenario-title">
|
3
|
+
<span class="permalink">
|
4
|
+
<a href="#<%= id %>">¶</a>
|
5
|
+
</span>
|
6
|
+
|
7
|
+
<span data-toggle="collapse" data-target="#<%= id %>_body">
|
8
|
+
"Scenario: <%= ERB::Util.h(name) %> Feature <%= feature_info %> at <%= run_time %> sec"
|
9
|
+
</span>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class="panel-collapse collapse" id="<%= id %>_body">
|
13
|
+
<div class="panel-body">
|
14
|
+
<ul class="tags">
|
15
|
+
<% tags.each do |tag| %>
|
16
|
+
<li>@<%= ERB::Util.h(tag) %></li>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
|
20
|
+
<div class="steps"><%= steps_html %></div>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</section>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<table>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Feature</th>
|
5
|
+
<th>Scenarios</th>
|
6
|
+
<th>passed</th>
|
7
|
+
<th>failed</th>
|
8
|
+
<th>pending</th>
|
9
|
+
<th>status</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% results.each do |info| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= info.name %></td>
|
16
|
+
<td><%= info.scenario_count %></td>
|
17
|
+
<td><%= info.passed_count %></td>
|
18
|
+
<td><%= info.failed_count %></td>
|
19
|
+
<td><%= info.pending_count %></td>
|
20
|
+
<td class="<%= info.status %>"><%= info.status %></td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<table>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Feature</th>
|
5
|
+
<th>Scenario</th>
|
6
|
+
<th>Duration</th>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
<% results.each do |info| %>
|
11
|
+
<tr>
|
12
|
+
<td>
|
13
|
+
<span><%= ERB::Util.h(info.feature_name) %></span>
|
14
|
+
</td>
|
15
|
+
<td>
|
16
|
+
<a href="#<%= info.id %>"><%= ERB::Util.h(info.name) %></a>
|
17
|
+
</td>
|
18
|
+
<td>
|
19
|
+
<span><%= info.run_time %> sec</span>
|
20
|
+
</td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<table>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Tag</th>
|
5
|
+
<th>Scenarios</th>
|
6
|
+
<th>passed</th>
|
7
|
+
<th>failed</th>
|
8
|
+
<th>pending</th>
|
9
|
+
<th>status</th>
|
10
|
+
</tr>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% results.each do |info| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= info.name %></td>
|
16
|
+
<td><%= info.scenario_count %></td>
|
17
|
+
<td><%= info.passed_count %></td>
|
18
|
+
<td><%= info.failed_count %></td>
|
19
|
+
<td><%= info.pending_count %></td>
|
20
|
+
<td class="<%= info.status %>"><%= info.status %></td>
|
21
|
+
</tr>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module TurnipFormatter
|
2
|
+
module Renderer
|
3
|
+
module Html
|
4
|
+
@script_codes = []
|
5
|
+
@script_files = []
|
6
|
+
@style_codes = []
|
7
|
+
@style_files = []
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :script_codes, :script_files, :style_codes, :style_files
|
11
|
+
|
12
|
+
def reset!
|
13
|
+
@script_codes = []
|
14
|
+
@script_files = []
|
15
|
+
@style_codes = []
|
16
|
+
@style_files = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def project_name
|
20
|
+
TurnipFormatter.configuration.title
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_javascript(script)
|
24
|
+
case
|
25
|
+
when local_file?(script)
|
26
|
+
script_codes << File.read(script)
|
27
|
+
when remote_url?(script)
|
28
|
+
script_files << script
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_stylesheet(stylesheet)
|
33
|
+
case
|
34
|
+
when local_file?(stylesheet)
|
35
|
+
style_codes << File.read(stylesheet)
|
36
|
+
when remote_url?(stylesheet)
|
37
|
+
style_files << stylesheet
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def render_javascript_codes
|
42
|
+
script_codes.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def render_javascript_links
|
46
|
+
script_files.map do |file|
|
47
|
+
"<script src=\"#{file}\"></script>"
|
48
|
+
end.join("\n")
|
49
|
+
end
|
50
|
+
|
51
|
+
def render_stylesheet_codes
|
52
|
+
style_codes.join("\n")
|
53
|
+
end
|
54
|
+
|
55
|
+
def render_stylesheet_links
|
56
|
+
style_files.map do |file|
|
57
|
+
"<link rel=\"stylesheet\" href=\"#{file}\">"
|
58
|
+
end.join("\n")
|
59
|
+
end
|
60
|
+
|
61
|
+
def render_step_template_stylesheet_codes
|
62
|
+
TurnipFormatter.step_templates.map do |template|
|
63
|
+
template.class.css
|
64
|
+
end.join("\n")
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def local_file?(path)
|
70
|
+
File.exist? path
|
71
|
+
end
|
72
|
+
|
73
|
+
def remote_url?(path)
|
74
|
+
uri = URI.parse(path)
|
75
|
+
return true if %w(http https).include?(uri.scheme)
|
76
|
+
return true if uri.scheme.nil? && path.start_with?('//')
|
77
|
+
false
|
78
|
+
rescue URI::InvalidURIError
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'turnip_formatter/resource/step'
|
3
|
+
|
4
|
+
module TurnipFormatter
|
5
|
+
module Resource
|
6
|
+
module Scenario
|
7
|
+
class Base
|
8
|
+
attr_reader :example
|
9
|
+
|
10
|
+
extend Forwardable
|
11
|
+
def_delegators :raw, :line, :keyword, :name, :steps
|
12
|
+
|
13
|
+
#
|
14
|
+
# @param [RSpec::Core::Example] example
|
15
|
+
#
|
16
|
+
def initialize(example)
|
17
|
+
@example = example
|
18
|
+
end
|
19
|
+
|
20
|
+
def steps
|
21
|
+
@steps ||= (backgrounds.map(&:steps).flatten + raw.steps).map do |step|
|
22
|
+
TurnipFormatter::Resource::Step.new(example, step)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def id
|
27
|
+
'scenario_' + object_id.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# @return [Symbol] scenario status (:passed | :failed | :pending)
|
32
|
+
#
|
33
|
+
def status
|
34
|
+
execution_result.status.to_sym
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# @return [Float] scenario run time (sec)
|
39
|
+
#
|
40
|
+
def run_time
|
41
|
+
execution_result.run_time
|
42
|
+
end
|
43
|
+
|
44
|
+
def feature_info
|
45
|
+
path = RSpec::Core::Metadata.relative_path(feature_file_path)
|
46
|
+
"\"#{feature.name}\" in #{path}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def backgrounds
|
50
|
+
feature.backgrounds
|
51
|
+
end
|
52
|
+
|
53
|
+
def tags
|
54
|
+
@tags ||= (feature.tag_names + raw.tag_names).sort.uniq
|
55
|
+
end
|
56
|
+
|
57
|
+
def feature
|
58
|
+
example.metadata[:turnip_formatter][:feature]
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def raw
|
64
|
+
@raw = example.metadata[:turnip_formatter][:scenario]
|
65
|
+
end
|
66
|
+
|
67
|
+
def feature_file_path
|
68
|
+
example.metadata[:file_path]
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# @return [OpenStruct or ::RSpec::Core::Example::ExecutionResult]
|
73
|
+
#
|
74
|
+
def execution_result
|
75
|
+
@execution_result ||= example.execution_result
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|