turnip_formatter 0.6.0.pre.beta.2 → 0.6.0.pre.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'slim'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Printer
|
5
|
-
#
|
6
|
-
# @example
|
7
|
-
# render_template(:main, { name: 'user' })
|
8
|
-
# # => Tilt.new('/path/to/main.erb') render { name: 'user' }
|
9
|
-
#
|
10
|
-
def render_template(name, params = {})
|
11
|
-
render_template_list(name).render(self, params)
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def render_template_list(name)
|
17
|
-
if templates[name].nil?
|
18
|
-
path = File.dirname(__FILE__) + "/template/#{name}.slim"
|
19
|
-
templates[name] = Slim::Template.new(path)
|
20
|
-
end
|
21
|
-
|
22
|
-
templates[name]
|
23
|
-
end
|
24
|
-
|
25
|
-
def templates
|
26
|
-
@templates ||= {}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'turnip_formatter/resource/step'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Scenario
|
5
|
-
class Base
|
6
|
-
attr_reader :errors, :example
|
7
|
-
|
8
|
-
#
|
9
|
-
# @param [RSpec::Core::Example] example
|
10
|
-
#
|
11
|
-
def initialize(example)
|
12
|
-
@example = example
|
13
|
-
@errors = []
|
14
|
-
|
15
|
-
validation
|
16
|
-
end
|
17
|
-
|
18
|
-
def valid?
|
19
|
-
errors.empty?
|
20
|
-
end
|
21
|
-
|
22
|
-
def steps
|
23
|
-
@steps ||= raw_steps.map do |step|
|
24
|
-
TurnipFormatter::Resource::Step.new(example, step)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def id
|
29
|
-
'scenario_' + object_id.to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# @return [String] scenario name
|
34
|
-
#
|
35
|
-
def name
|
36
|
-
example.example_group.description
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# @return [String] scenario status ('passed', 'failed' or 'pending')
|
41
|
-
#
|
42
|
-
def status
|
43
|
-
execution_result.status.to_s
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# @return [String] scenario run time
|
48
|
-
#
|
49
|
-
def run_time
|
50
|
-
execution_result.run_time
|
51
|
-
end
|
52
|
-
|
53
|
-
def feature_info
|
54
|
-
path = RSpec::Core::Metadata.relative_path(feature_file_path)
|
55
|
-
"\"#{feature_name}\" in #{path}"
|
56
|
-
end
|
57
|
-
|
58
|
-
def feature_name
|
59
|
-
parent_example_group[:description]
|
60
|
-
end
|
61
|
-
|
62
|
-
def tags
|
63
|
-
example.metadata[:turnip_formatter][:tags]
|
64
|
-
end
|
65
|
-
|
66
|
-
protected
|
67
|
-
|
68
|
-
def validation
|
69
|
-
unless example.metadata.key?(:turnip_formatter)
|
70
|
-
@errors << 'has no steps information'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def feature_file_path
|
77
|
-
example.metadata[:file_path]
|
78
|
-
end
|
79
|
-
|
80
|
-
def raw_steps
|
81
|
-
example.metadata[:turnip_formatter][:steps]
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# @return [Hash] parent example group
|
86
|
-
#
|
87
|
-
def parent_example_group
|
88
|
-
example.example_group.metadata[:parent_example_group]
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
# @return [OpenStruct or ::RSpec::Core::Example::ExecutionResult]
|
93
|
-
#
|
94
|
-
def execution_result
|
95
|
-
@execution_result ||= example.execution_result
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'turnip_formatter/scenario/base'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Scenario
|
5
|
-
class Failure < Base
|
6
|
-
def steps
|
7
|
-
steps = super
|
8
|
-
return steps unless failed_line_number
|
9
|
-
|
10
|
-
steps.each do |step|
|
11
|
-
case
|
12
|
-
when step.line == failed_line_number
|
13
|
-
step.status = :failed
|
14
|
-
when step.line > failed_line_number
|
15
|
-
step.status = :unexecuted
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
steps
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
def validation
|
25
|
-
@errors << 'has no failed step information' unless failed_line_number
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def failed_line_number
|
32
|
-
return @failed_line_number if @failed_line_number
|
33
|
-
return unless example.exception
|
34
|
-
|
35
|
-
filepath = File.basename(feature_file_path)
|
36
|
-
line = example.exception.backtrace.find do |backtrace|
|
37
|
-
backtrace.match(/#{filepath}:(\d+)/)
|
38
|
-
end
|
39
|
-
|
40
|
-
@failed_line_number = Regexp.last_match[1].to_i if line
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'turnip_formatter/scenario/base'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Scenario
|
5
|
-
class Pending < Base
|
6
|
-
def steps
|
7
|
-
steps = super
|
8
|
-
return steps unless pending_line_number
|
9
|
-
|
10
|
-
steps.each do |step|
|
11
|
-
case
|
12
|
-
when step.line == pending_line_number
|
13
|
-
step.status = :pending
|
14
|
-
when step.line > pending_line_number
|
15
|
-
step.status = :unexecuted
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
steps
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
def validation
|
25
|
-
@errors << 'has no pending step information' unless pending_line_number
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def pending_line_number
|
32
|
-
example.metadata[:line_number]
|
33
|
-
end
|
34
|
-
|
35
|
-
def pending_message
|
36
|
-
example.execution_result.pending_message
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
class Step
|
5
|
-
extend Forwardable
|
6
|
-
|
7
|
-
attr_reader :name, :example, :argument
|
8
|
-
attr_accessor :status
|
9
|
-
|
10
|
-
def_delegators :@raw, :argument, :line, :keyword, :description
|
11
|
-
|
12
|
-
#
|
13
|
-
# @param [RSpec::Core::Example] example
|
14
|
-
# @param [Turnip::Node::Step] raw
|
15
|
-
#
|
16
|
-
def initialize(example, raw)
|
17
|
-
@example = example
|
18
|
-
@raw = raw
|
19
|
-
@name = raw.keyword.strip + ' ' + raw.description
|
20
|
-
@status = :passed
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
doctype 5
|
2
|
-
html
|
3
|
-
head
|
4
|
-
meta charset=("UTF-8")
|
5
|
-
title= TurnipFormatter::Template.project_name + ' report'
|
6
|
-
|
7
|
-
== TurnipFormatter::Template.render_stylesheet_links
|
8
|
-
style== TurnipFormatter::Template.render_stylesheet_codes
|
9
|
-
|
10
|
-
script src="https://code.jquery.com/jquery-1.11.0.min.js"
|
11
|
-
script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"
|
12
|
-
script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.17.0/jquery.tablesorter.min.js"
|
13
|
-
|
14
|
-
== TurnipFormatter::Template.render_javascript_links
|
15
|
-
script== TurnipFormatter::Template.render_javascript_codes
|
16
|
-
|
17
|
-
body
|
18
|
-
header#report
|
19
|
-
.container
|
20
|
-
.page-header
|
21
|
-
h1 = "#{TurnipFormatter::Template.project_name} Report"
|
22
|
-
|
23
|
-
section#status_display_switch
|
24
|
-
label for="passed_check"
|
25
|
-
input#passed_check type="checkbox"
|
26
|
-
| Passed
|
27
|
-
label for="failed_check"
|
28
|
-
input#failed_check type="checkbox" checked="checked"
|
29
|
-
| Failed
|
30
|
-
label for="pending_check"
|
31
|
-
input#pending_check type="checkbox"
|
32
|
-
| Pending
|
33
|
-
|
34
|
-
section.result
|
35
|
-
p = "#{scenarios.size} Scenario (#{failed_count} failed #{pending_count} pending)."
|
36
|
-
p = "Finished in #{total_time.to_s} sec"
|
37
|
-
|
38
|
-
#main.container role="main"
|
39
|
-
ul#statistics class="nav nav-tabs"
|
40
|
-
li.active
|
41
|
-
a data-toggle="tab" href="#steps-statistics"
|
42
|
-
| Steps
|
43
|
-
li
|
44
|
-
a data-toggle="tab" href="#speed-statistics"
|
45
|
-
| Speed Statistics
|
46
|
-
li
|
47
|
-
a data-toggle="tab" href="#feature-statistics"
|
48
|
-
| Feature Statistics
|
49
|
-
li
|
50
|
-
a data-toggle="tab" href="#tag-statistics"
|
51
|
-
| Tag Statistics
|
52
|
-
|
53
|
-
.tab-content
|
54
|
-
#steps-statistics class="tab-pane active"
|
55
|
-
.checkbox
|
56
|
-
label
|
57
|
-
input#scenario_display_check type="checkbox" checked="checked"
|
58
|
-
| Folding
|
59
|
-
#scenarios.panel-group
|
60
|
-
- scenarios.each do |s|
|
61
|
-
== ::TurnipFormatter::Printer::Scenario.print_out(s)
|
62
|
-
|
63
|
-
#feature-statistics.tab-pane
|
64
|
-
h4 The results for the feature:
|
65
|
-
== TurnipFormatter::Printer::TabFeatureStatistics.print_out(scenarios)
|
66
|
-
|
67
|
-
#tag-statistics.tab-pane
|
68
|
-
h4 The results for the tab:
|
69
|
-
== TurnipFormatter::Printer::TabTagStatistics.print_out(scenarios)
|
70
|
-
|
71
|
-
#speed-statistics.tab-pane
|
72
|
-
h4 Ranking of running time of each <strong>successfully</strong> scenario:
|
73
|
-
== TurnipFormatter::Printer::TabSpeedStatistics.print_out(scenarios)
|
74
|
-
|
75
|
-
footer
|
76
|
-
p
|
77
|
-
| Generated by
|
78
|
-
a href="https://rubygems.org/gems/turnip_formatter"
|
79
|
-
= "turnip_formatter #{TurnipFormatter::VERSION}"
|
80
|
-
p
|
81
|
-
| Powered by
|
82
|
-
a href="http://jquery.com/"
|
83
|
-
| jQuery 1.11.0
|
84
|
-
| and
|
85
|
-
a href="http://mottie.github.io/tablesorter/"
|
86
|
-
| tablesorter 2.17.0
|
@@ -1,13 +0,0 @@
|
|
1
|
-
section.exception
|
2
|
-
h1 TurnipFormatter RuntimeError
|
3
|
-
dl
|
4
|
-
== runtime_exception
|
5
|
-
|
6
|
-
dt Example Full Description
|
7
|
-
dd= example.metadata[:full_description]
|
8
|
-
|
9
|
-
== example_exception
|
10
|
-
|
11
|
-
- if example.pending
|
12
|
-
dt Example Pending description
|
13
|
-
dd= example.metadata[:description]
|
@@ -1,15 +0,0 @@
|
|
1
|
-
section class="scenario #{scenario.status}" id=scenario.id
|
2
|
-
div.scenario-title
|
3
|
-
span.permalink
|
4
|
-
a href="##{scenario.id}"
|
5
|
-
| ¶
|
6
|
-
span data-toggle="collapse" data-target="##{scenario.id}_body"
|
7
|
-
= "Scenario: #{scenario.name} Feature #{scenario.feature_info} at #{scenario.run_time} sec"
|
8
|
-
div class="panel-collapse collapse" id="#{scenario.id}_body"
|
9
|
-
div.panel-body
|
10
|
-
ul.tags
|
11
|
-
- scenario.tags.each do |tag|
|
12
|
-
li = "@#{tag}"
|
13
|
-
div.steps
|
14
|
-
- scenario.steps.each do |step|
|
15
|
-
== TurnipFormatter::Renderer::Html::Step.new(step).render
|
@@ -1,18 +0,0 @@
|
|
1
|
-
table
|
2
|
-
thead
|
3
|
-
tr
|
4
|
-
th Feature
|
5
|
-
th Scenarios
|
6
|
-
th passed
|
7
|
-
th failed
|
8
|
-
th pending
|
9
|
-
th status
|
10
|
-
tbody
|
11
|
-
- analysis_results.each do |info|
|
12
|
-
tr
|
13
|
-
td= info.name
|
14
|
-
td= info.scenario_count
|
15
|
-
td= info.passed_count
|
16
|
-
td= info.failed_count
|
17
|
-
td= info.pending_count
|
18
|
-
td class=info.status = info.status
|
@@ -1,18 +0,0 @@
|
|
1
|
-
table
|
2
|
-
thead
|
3
|
-
tr
|
4
|
-
th Tag
|
5
|
-
th Scenarios
|
6
|
-
th passed
|
7
|
-
th failed
|
8
|
-
th pending
|
9
|
-
th status
|
10
|
-
tbody
|
11
|
-
- analysis_results.each do |info|
|
12
|
-
tr
|
13
|
-
td= info.name
|
14
|
-
td= info.scenario_count
|
15
|
-
td= info.passed_count
|
16
|
-
td= info.failed_count
|
17
|
-
td= info.pending_count
|
18
|
-
td class=info.status = info.status
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/printer/index'
|
3
|
-
|
4
|
-
module TurnipFormatter::Printer
|
5
|
-
describe Index do
|
6
|
-
|
7
|
-
let(:formatter) do
|
8
|
-
{
|
9
|
-
scenarios: [],
|
10
|
-
scenario_files: [],
|
11
|
-
failed_count: 0,
|
12
|
-
pending_count: 0,
|
13
|
-
duration: 0
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
subject { Index.print_out(formatter) }
|
18
|
-
|
19
|
-
describe '.print_out' do
|
20
|
-
it { should match %r{<h1>Turnip Report</h1>} }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'project_name is changed' do
|
24
|
-
before do
|
25
|
-
@original_project_name = TurnipFormatter.configuration.title
|
26
|
-
TurnipFormatter.configuration.title = 'My Project'
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '.print_out' do
|
30
|
-
it { should match %r{<h1>My Project Report</h1>} }
|
31
|
-
end
|
32
|
-
|
33
|
-
after do
|
34
|
-
TurnipFormatter.configuration.title = @original_project_name
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/printer/scenario'
|
3
|
-
|
4
|
-
describe TurnipFormatter::Printer::Scenario do
|
5
|
-
let(:example) do
|
6
|
-
passed_example
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:scenario) do
|
10
|
-
TurnipFormatter::Scenario::Pass.new(example)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '.print_out' do
|
14
|
-
context 'with turnip example' do
|
15
|
-
subject { described_class.print_out(scenario) }
|
16
|
-
|
17
|
-
it { should match %r{<a .*href="##{scenario.id}"} }
|
18
|
-
it { should match %r{<div class="scenario-title">.*Scenario: Scenario} }
|
19
|
-
it { should match %{<ul class="tags">} }
|
20
|
-
it { should match %{<div class="steps} }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'with no turnip example' do
|
24
|
-
let(:example) do
|
25
|
-
passed_example.tap { |e| e.metadata.delete(:turnip_formatter) }
|
26
|
-
end
|
27
|
-
|
28
|
-
subject { described_class.print_out(scenario) }
|
29
|
-
|
30
|
-
it { should be nil }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'runtime error' do
|
34
|
-
before do
|
35
|
-
allow(scenario).to receive(:valid?) { raise StandardError }
|
36
|
-
expect(TurnipFormatter::Printer::RuntimeError).to receive(:print_out)
|
37
|
-
end
|
38
|
-
|
39
|
-
it { described_class.print_out(scenario) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/printer/tab_feature_statistics'
|
3
|
-
|
4
|
-
module TurnipFormatter::Printer
|
5
|
-
describe TabFeatureStatistics do
|
6
|
-
let :base_scenario do
|
7
|
-
TurnipFormatter::Scenario::Pass.new(passed_example)
|
8
|
-
end
|
9
|
-
|
10
|
-
let :statistics do
|
11
|
-
TurnipFormatter::Printer::TabFeatureStatistics
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'feature only passed scenario' do
|
15
|
-
let :scenarios do
|
16
|
-
# Feature: Hago (passed:2 failed:0, pending:0)
|
17
|
-
['passed', 'passed'].map do |status|
|
18
|
-
scenario = base_scenario.dup
|
19
|
-
allow(scenario).to receive(:status).and_return(status)
|
20
|
-
scenario
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '.feature_analysis' do
|
25
|
-
it 'should get passed feature information' do
|
26
|
-
info = statistics.send(:feature_analysis, 'Hoge', scenarios)
|
27
|
-
expect(info.name).to eq 'Hoge'
|
28
|
-
expect(info.passed_count).to eq 2
|
29
|
-
expect(info.failed_count).to be_zero
|
30
|
-
expect(info.pending_count).to be_zero
|
31
|
-
expect(info.status).to eq 'passed'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'feature with failed scenario' do
|
37
|
-
let :scenarios do
|
38
|
-
# Feature: Hoge (passed:1 failed:2, pending:0)
|
39
|
-
['passed', 'failed', 'failed'].map do |status|
|
40
|
-
scenario = base_scenario.dup
|
41
|
-
allow(scenario).to receive(:status).and_return(status)
|
42
|
-
scenario
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.feature_analysis' do
|
47
|
-
it 'should get failed feature information' do
|
48
|
-
info = statistics.send(:feature_analysis, 'Fuga', scenarios)
|
49
|
-
expect(info.name).to eq 'Fuga'
|
50
|
-
expect(info.passed_count).to eq 1
|
51
|
-
expect(info.failed_count).to eq 2
|
52
|
-
expect(info.pending_count).to be_zero
|
53
|
-
expect(info.status).to eq 'failed'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'feature with pending scenario' do
|
59
|
-
let :scenarios do
|
60
|
-
# Feature: Fuga (passed:1 failed:0, pending:1)
|
61
|
-
['passed', 'pending'].map do |status|
|
62
|
-
scenario = base_scenario.dup
|
63
|
-
allow(scenario).to receive(:status).and_return(status)
|
64
|
-
scenario
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '.feature_analysis' do
|
69
|
-
it 'should get pending feature information' do
|
70
|
-
info = statistics.send(:feature_analysis, 'Hago', scenarios)
|
71
|
-
expect(info.name).to eq 'Hago'
|
72
|
-
expect(info.passed_count).to eq 1
|
73
|
-
expect(info.failed_count).to be_zero
|
74
|
-
expect(info.pending_count).to eq 1
|
75
|
-
expect(info.status).to eq 'pending'
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/printer/tab_speed_statistics'
|
3
|
-
|
4
|
-
module TurnipFormatter::Printer
|
5
|
-
describe TabSpeedStatistics do
|
6
|
-
let :statistics do
|
7
|
-
TurnipFormatter::Printer::TabSpeedStatistics
|
8
|
-
end
|
9
|
-
|
10
|
-
let :passed_scenarios do
|
11
|
-
([passed_example] * 3).map do |ex|
|
12
|
-
TurnipFormatter::Scenario::Pass.new(ex)
|
13
|
-
end.each { |s| allow(s).to receive(:run_time).and_return(rand) }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.print_out' do
|
17
|
-
it 'should get string as HTML table' do
|
18
|
-
html = statistics.print_out(passed_scenarios)
|
19
|
-
|
20
|
-
passed_scenarios.sort { |a,b| a.run_time <=> b.run_time }.each.with_index(1) do |scenario, index|
|
21
|
-
tag_feature_name = "<span>#{scenario.feature_name}</span>"
|
22
|
-
tag_scenario_name = "<a href=\"\##{scenario.id}\">#{scenario.name}</a>"
|
23
|
-
tag_run_time = "<span>#{scenario.run_time} sec</span>"
|
24
|
-
|
25
|
-
expect_match = [
|
26
|
-
'<tr>',
|
27
|
-
"<td>#{tag_feature_name}</td>",
|
28
|
-
"<td>#{tag_scenario_name}</td>",
|
29
|
-
"<td>#{tag_run_time}</td>",
|
30
|
-
'</tr>'
|
31
|
-
].join
|
32
|
-
|
33
|
-
expect(html).to match %r(#{expect_match})
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '.speed_analysis' do
|
39
|
-
it 'should get array of scenario order by run_time' do
|
40
|
-
scenarios = statistics.send(:speed_analysis, passed_scenarios)
|
41
|
-
expect(scenarios.size).to eq 3
|
42
|
-
|
43
|
-
run_time_list = scenarios.map(&:run_time)
|
44
|
-
expect(run_time_list.sort).to eq run_time_list
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|