turnip_formatter 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/turnip_formatter/printer/tab_feature_statistics.rb +9 -10
- data/lib/turnip_formatter/printer/tab_speed_statistics.rb +1 -1
- data/lib/turnip_formatter/printer/tab_tag_statistics.rb +9 -9
- data/lib/turnip_formatter/template/tab_feature_statistics.erb +4 -4
- data/lib/turnip_formatter/template/tab_tag_statistics.erb +4 -4
- data/lib/turnip_formatter/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/turnip_formatter/printer/scenario_spec.rb +5 -2
- data/spec/turnip_formatter/printer/step_extra_args_spec.rb +13 -4
- data/spec/turnip_formatter/printer/step_spec.rb +7 -4
- data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +9 -9
- data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +6 -14
- data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +24 -12
- data/turnip_formatter.gemspec +1 -1
- metadata +12 -12
@@ -16,31 +16,30 @@ module TurnipFormatter
|
|
16
16
|
feature_analysis(name, feature_scenarios)
|
17
17
|
end
|
18
18
|
|
19
|
-
render_template(:tab_feature_statistics, {analysis_results: results })
|
19
|
+
render_template(:tab_feature_statistics, { analysis_results: results })
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
24
|
def feature_analysis(name, scenarios)
|
25
25
|
status_group = scenarios.group_by { |s| s.status }
|
26
|
+
status_group.default = []
|
26
27
|
|
27
28
|
info = OpenStruct.new(
|
28
29
|
name: name,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
scenario_count: scenarios.size,
|
31
|
+
passed_count: status_group["passed"].size,
|
32
|
+
failed_count: status_group["failed"].size,
|
33
|
+
pending_count: status_group["pending"].size,
|
33
34
|
status: 'failed'
|
34
35
|
)
|
35
36
|
|
36
|
-
|
37
|
+
if info.failed_count.zero?
|
38
|
+
info.status = info.pending_count.zero? ? 'passed' : 'pending'
|
39
|
+
end
|
37
40
|
|
38
41
|
info
|
39
42
|
end
|
40
|
-
|
41
|
-
def status_count(scenarios)
|
42
|
-
scenarios.nil? ? 0 : scenarios.count
|
43
|
-
end
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
@@ -11,7 +11,7 @@ module TurnipFormatter
|
|
11
11
|
|
12
12
|
def print_out(passed_scenarios)
|
13
13
|
results = speed_analysis(passed_scenarios)
|
14
|
-
render_template(:tab_speed_statistics, {analysis_results: results })
|
14
|
+
render_template(:tab_speed_statistics, { analysis_results: results })
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
@@ -23,17 +23,21 @@ module TurnipFormatter
|
|
23
23
|
|
24
24
|
def tag_analysis(name, scenarios)
|
25
25
|
status_group = scenarios.group_by { |s| s[:scenario].status }
|
26
|
+
status_group.default = []
|
26
27
|
|
27
28
|
info = OpenStruct.new(
|
28
29
|
name: name,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
scenario_count: scenarios.size,
|
31
|
+
passed_count: status_group["passed"].size,
|
32
|
+
failed_count: status_group["failed"].size,
|
33
|
+
pending_count: status_group["pending"].size,
|
33
34
|
status: 'failed'
|
34
35
|
)
|
35
36
|
|
36
|
-
|
37
|
+
if info.failed_count.zero?
|
38
|
+
info.status = info.pending_count.zero? ? 'passed' : 'pending'
|
39
|
+
end
|
40
|
+
|
37
41
|
info
|
38
42
|
end
|
39
43
|
|
@@ -62,10 +66,6 @@ module TurnipFormatter
|
|
62
66
|
end
|
63
67
|
end.flatten.group_by { |s| s[:name] }.sort
|
64
68
|
end
|
65
|
-
|
66
|
-
def status_count(scenarios)
|
67
|
-
scenarios.nil? ? 0 : scenarios.count
|
68
|
-
end
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -13,10 +13,10 @@
|
|
13
13
|
<% analysis_results.each do |info| %>
|
14
14
|
<tr>
|
15
15
|
<td><%= info.name %></td>
|
16
|
-
<td><%= info.
|
17
|
-
<td><%= info.
|
18
|
-
<td><%= info.
|
19
|
-
<td><%= info.
|
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
20
|
<td class="<%= info.status %>"><%= info.status %></td>
|
21
21
|
</tr>
|
22
22
|
<% end %>
|
@@ -13,10 +13,10 @@
|
|
13
13
|
<% analysis_results.each do |info| %>
|
14
14
|
<tr>
|
15
15
|
<td><%= info.name %></td>
|
16
|
-
<td><%= info.
|
17
|
-
<td><%= info.
|
18
|
-
<td><%= info.
|
19
|
-
<td><%= info.
|
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
20
|
<td class="<%= info.status %>"><%= info.status %></td>
|
21
21
|
</tr>
|
22
22
|
<% end %>
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,10 @@ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
5
5
|
SimpleCov.start do
|
6
6
|
add_filter 'spec/'
|
7
7
|
add_filter 'vendor/'
|
8
|
+
add_filter 'lib/turnip_formatter/ext'
|
8
9
|
end
|
9
10
|
|
11
|
+
require 'rspec-html-matchers'
|
10
12
|
require 'turnip_formatter'
|
11
13
|
Dir.glob(File.dirname(__FILE__) + "/support/**/*.rb") { |f| require(f) }
|
12
14
|
|
@@ -14,8 +14,11 @@ module TurnipFormatter::Printer
|
|
14
14
|
describe '.print_out' do
|
15
15
|
subject { Scenario.print_out(scenario) }
|
16
16
|
|
17
|
-
it { should
|
18
|
-
it { should
|
17
|
+
it { should have_tag 'a', with: { href: '#' + scenario.id } }
|
18
|
+
it { should have_tag 'span.scenario_name', text: /Scenario: Scenario/ }
|
19
|
+
it { should have_tag 'span.feature_name' }
|
20
|
+
it { should have_tag 'ul.tags' }
|
21
|
+
it { should have_tag 'ul.steps' }
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -15,9 +15,18 @@ module TurnipFormatter::Printer
|
|
15
15
|
|
16
16
|
subject { StepExtraArgs.print_out([string]) }
|
17
17
|
|
18
|
-
it {
|
19
|
-
|
20
|
-
|
18
|
+
it {
|
19
|
+
subject.should have_tag 'table.step_outline' do
|
20
|
+
with_tag 'tr:nth-child(1) td:nth-child(1)', text: 'State'
|
21
|
+
with_tag 'tr:nth-child(1) td:nth-child(2)', text: 'Money'
|
22
|
+
|
23
|
+
with_tag 'tr:nth-child(2) td:nth-child(1)', text: '<Tokushima>'
|
24
|
+
with_tag 'tr:nth-child(2) td:nth-child(2)', text: '555'
|
25
|
+
|
26
|
+
with_tag 'tr:nth-child(3) td:nth-child(1)', text: '<Okinawa>'
|
27
|
+
with_tag 'tr:nth-child(3) td:nth-child(2)', text: '368'
|
28
|
+
end
|
29
|
+
}
|
21
30
|
end
|
22
31
|
end
|
23
32
|
|
@@ -25,7 +34,7 @@ module TurnipFormatter::Printer
|
|
25
34
|
describe '.print_out' do
|
26
35
|
let(:string) { 'a<a>a' }
|
27
36
|
subject { StepExtraArgs.print_out([string]) }
|
28
|
-
it { should
|
37
|
+
it { should have_tag 'pre.multiline', text: 'a<a>a' }
|
29
38
|
end
|
30
39
|
end
|
31
40
|
end
|
@@ -28,7 +28,7 @@ module TurnipFormatter::Printer
|
|
28
28
|
exception_style.should_receive(:build).with('c').and_return('exception')
|
29
29
|
end
|
30
30
|
|
31
|
-
it { should
|
31
|
+
it { should have_tag 'div.args', text: "extra_args\nsource\nexception" }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -37,7 +37,7 @@ module TurnipFormatter::Printer
|
|
37
37
|
let(:custom_template_1) do
|
38
38
|
Module.new do
|
39
39
|
def self.build(value)
|
40
|
-
"<
|
40
|
+
"<em>#{value}</em>"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -60,7 +60,10 @@ module TurnipFormatter::Printer
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should call corresponding method in step' do
|
63
|
-
should
|
63
|
+
subject.should have_tag 'div.args' do
|
64
|
+
with_tag 'em', text: 'aiueo'
|
65
|
+
with_tag 'strong', text: '12345'
|
66
|
+
end
|
64
67
|
end
|
65
68
|
end
|
66
69
|
end
|
@@ -78,7 +81,7 @@ module TurnipFormatter::Printer
|
|
78
81
|
exception_style.should_not_receive(:build)
|
79
82
|
end
|
80
83
|
|
81
|
-
it { should
|
84
|
+
it { should have_tag 'div.args', text: '' }
|
82
85
|
end
|
83
86
|
end
|
84
87
|
end
|
@@ -28,9 +28,9 @@ module TurnipFormatter::Printer
|
|
28
28
|
it 'should get passed feature information' do
|
29
29
|
info = statistics.send(:feature_analysis, 'Hoge', scenarios)
|
30
30
|
expect(info.name).to eq 'Hoge'
|
31
|
-
expect(info.
|
32
|
-
expect(info.
|
33
|
-
expect(info.
|
31
|
+
expect(info.passed_count).to eq 2
|
32
|
+
expect(info.failed_count).to be_zero
|
33
|
+
expect(info.pending_count).to be_zero
|
34
34
|
expect(info.status).to eq 'passed'
|
35
35
|
end
|
36
36
|
end
|
@@ -50,9 +50,9 @@ module TurnipFormatter::Printer
|
|
50
50
|
it 'should get failed feature information' do
|
51
51
|
info = statistics.send(:feature_analysis, 'Fuga', scenarios)
|
52
52
|
expect(info.name).to eq 'Fuga'
|
53
|
-
expect(info.
|
54
|
-
expect(info.
|
55
|
-
expect(info.
|
53
|
+
expect(info.passed_count).to eq 1
|
54
|
+
expect(info.failed_count).to eq 2
|
55
|
+
expect(info.pending_count).to be_zero
|
56
56
|
expect(info.status).to eq 'failed'
|
57
57
|
end
|
58
58
|
end
|
@@ -72,9 +72,9 @@ module TurnipFormatter::Printer
|
|
72
72
|
it 'should get pending feature information' do
|
73
73
|
info = statistics.send(:feature_analysis, 'Hago', scenarios)
|
74
74
|
expect(info.name).to eq 'Hago'
|
75
|
-
expect(info.
|
76
|
-
expect(info.
|
77
|
-
expect(info.
|
75
|
+
expect(info.passed_count).to eq 1
|
76
|
+
expect(info.failed_count).to be_zero
|
77
|
+
expect(info.pending_count).to eq 1
|
78
78
|
expect(info.status).to eq 'pending'
|
79
79
|
end
|
80
80
|
end
|
@@ -20,20 +20,12 @@ module TurnipFormatter::Printer
|
|
20
20
|
it 'should get string as HTML table' do
|
21
21
|
html = statistics.print_out(passed_scenarios)
|
22
22
|
|
23
|
-
passed_scenarios.each do |scenario|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
'<tr>',
|
30
|
-
"<td>#{tag_feature_name}</td>",
|
31
|
-
"<td>#{tag_scenario_name}</td>",
|
32
|
-
"<td>#{tag_run_time} sec</td>",
|
33
|
-
'</tr>'
|
34
|
-
].join('[[:space:]]+')
|
35
|
-
|
36
|
-
expect(html).to match %r(#{expect_match})
|
23
|
+
passed_scenarios.sort { |a,b| a.run_time <=> b.run_time }.each.with_index(1) do |scenario, index|
|
24
|
+
html.should have_tag "tbody tr:nth-child(#{index})" do
|
25
|
+
with_tag 'td:nth-child(1) span', text: scenario.feature_name
|
26
|
+
with_tag "td:nth-child(2) a[href='\##{scenario.id}']", text: scenario.name
|
27
|
+
with_tag 'td:nth-child(3) span', text: scenario.run_time
|
28
|
+
end
|
37
29
|
end
|
38
30
|
end
|
39
31
|
end
|
@@ -63,27 +63,39 @@ module TurnipFormatter::Printer
|
|
63
63
|
it 'should get count of each status' do
|
64
64
|
# @bar
|
65
65
|
group = groups[0]
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
67
|
+
expect(result.passed_count).to eq 0
|
68
|
+
expect(result.failed_count).to eq 1
|
69
|
+
expect(result.pending_count).to eq 1
|
70
|
+
expect(result.status).to eq 'failed'
|
71
|
+
end
|
69
72
|
|
70
73
|
# @foo
|
71
74
|
group = groups[1]
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
76
|
+
expect(result.passed_count).to eq 0
|
77
|
+
expect(result.failed_count).to eq 1
|
78
|
+
expect(result.pending_count).to eq 0
|
79
|
+
expect(result.status).to eq 'failed'
|
80
|
+
end
|
75
81
|
|
76
82
|
# @hoge
|
77
83
|
group = groups[2]
|
78
|
-
|
79
|
-
|
80
|
-
|
84
|
+
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
85
|
+
expect(result.passed_count).to eq 1
|
86
|
+
expect(result.failed_count).to eq 0
|
87
|
+
expect(result.pending_count).to eq 1
|
88
|
+
expect(result.status).to eq 'pending'
|
89
|
+
end
|
81
90
|
|
82
91
|
# no tags (turnip)
|
83
92
|
group = groups[3]
|
84
|
-
|
85
|
-
|
86
|
-
|
93
|
+
statistics.send(:tag_analysis, group[0], group[1]).tap do |result|
|
94
|
+
expect(result.passed_count).to eq 1
|
95
|
+
expect(result.failed_count).to eq 0
|
96
|
+
expect(result.pending_count).to eq 0
|
97
|
+
expect(result.status).to eq 'passed'
|
98
|
+
end
|
87
99
|
end
|
88
100
|
end
|
89
101
|
end
|
data/turnip_formatter.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'sass'
|
23
23
|
spec.add_dependency 'uglifier'
|
24
24
|
spec.add_dependency 'therubyracer'
|
25
|
-
spec.add_dependency 'rspec', '~> 2.13.0'
|
26
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
26
|
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency 'rspec-html-matchers'
|
28
28
|
spec.add_development_dependency 'coveralls'
|
29
29
|
spec.add_development_dependency 'guard-rspec'
|
30
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turnip_formatter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: turnip
|
@@ -76,39 +76,39 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: bundler
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
86
|
-
type: :
|
85
|
+
version: '1.3'
|
86
|
+
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: '1.3'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
95
|
+
name: rake
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
101
|
+
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
109
|
+
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
111
|
+
name: rspec-html-matchers
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|