turnip_formatter 0.0.6 → 0.1.0

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.
@@ -19,17 +19,25 @@ module RSpec::Core::Formatters
19
19
  end
20
20
 
21
21
  describe '#example_passed' do
22
- it 'should be output passed scenario section' do
22
+ before do
23
23
  scenario.example('passed', metadata) { expect(true).to be_true }
24
24
  feature.run(formatter)
25
+ end
25
26
 
27
+ it 'should be output passed scenario section' do
26
28
  string = output.string
27
29
  expect(string).to match 'class="scenario passed"'
28
30
  end
31
+
32
+ it 'should get passed scenario count' do
33
+ expect(formatter.passed_scenarios).to have(1).elements
34
+ expect(formatter.failed_scenarios).to have(0).elements
35
+ expect(formatter.pending_scenarios).to have(0).elements
36
+ end
29
37
  end
30
38
 
31
39
  describe '#example_failed' do
32
- it 'should be output failed scenario section' do
40
+ before do
33
41
  scenario.example('failed', metadata) do
34
42
  begin
35
43
  expect(true).to be_false
@@ -38,29 +46,36 @@ module RSpec::Core::Formatters
38
46
  raise e
39
47
  end
40
48
  end
41
-
42
49
  feature.run(formatter)
50
+ end
51
+
52
+ it 'should be output failed scenario section' do
43
53
  expect(output.string).to match 'class="scenario failed"'
44
54
  end
55
+
56
+ it 'should get failed scenario count' do
57
+ expect(formatter.passed_scenarios).to have(0).elements
58
+ expect(formatter.failed_scenarios).to have(1).elements
59
+ expect(formatter.pending_scenarios).to have(0).elements
60
+ end
45
61
  end
46
62
 
47
63
  describe '#example_pending' do
48
- it 'should be output pending scenario section' do
64
+ before do
49
65
  scenario.example('pending', metadata) do
50
66
  pending("No such step(0): 'this step is unimplement'")
51
67
  end
52
68
  feature.run(formatter)
69
+ end
53
70
 
71
+ it 'should be output pending scenario section' do
54
72
  expect(output.string).to match 'class="scenario pending"'
55
73
  end
56
74
 
57
- it 'should be output runtime exception section' do
58
- scenario.example('pending', metadata) do
59
- pending("Pending")
60
- end
61
- feature.run(formatter)
62
-
63
- expect(output.string).to match 'class="exception"'
75
+ it 'should get pending scenario count' do
76
+ expect(formatter.passed_scenarios).to have(0).elements
77
+ expect(formatter.failed_scenarios).to have(0).elements
78
+ expect(formatter.pending_scenarios).to have(1).elements
64
79
  end
65
80
  end
66
81
 
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/template/tab/feature_statistics'
3
+
4
+ module TurnipFormatter
5
+ class Template
6
+ module Tab
7
+ describe FeatureStatistics do
8
+ include_context 'turnip_formatter scenario setup'
9
+ include_context 'turnip_formatter standard scenario metadata'
10
+
11
+ let :base_scenario do
12
+ TurnipFormatter::Scenario::Pass.new(example)
13
+ end
14
+
15
+ let :statistics do
16
+ FeatureStatistics.new(scenarios)
17
+ end
18
+
19
+ context 'feature only passed scenario' do
20
+ let :scenarios do
21
+ # Feature: Hago (passed:2 failed:0, pending:0)
22
+ ['passed', 'passed'].map do |status|
23
+ scenario = base_scenario.dup
24
+ scenario.stub(:status).and_return(status)
25
+ scenario
26
+ end
27
+ end
28
+
29
+ describe '#feature_analysis' do
30
+ it 'should get passed feature information' do
31
+ info = statistics.send(:feature_analysis, 'Hoge', scenarios)
32
+ expect(info[:name]).to eq 'Hoge'
33
+ expect(info[:passed]).to eq 2
34
+ expect(info[:failed]).to be_zero
35
+ expect(info[:pending]).to be_zero
36
+ expect(info[:status]).to eq 'passed'
37
+ end
38
+ end
39
+ end
40
+
41
+ context 'feature with failed scenario' do
42
+ let :scenarios do
43
+ # Feature: Hoge (passed:1 failed:2, pending:0)
44
+ ['passed', 'failed', 'failed'].map do |status|
45
+ scenario = base_scenario.dup
46
+ scenario.stub(:status).and_return(status)
47
+ scenario
48
+ end
49
+ end
50
+
51
+ describe '#feature_analysis' do
52
+ it 'should get failed feature information' do
53
+ info = statistics.send(:feature_analysis, 'Fuga', scenarios)
54
+ expect(info[:name]).to eq 'Fuga'
55
+ expect(info[:passed]).to eq 1
56
+ expect(info[:failed]).to eq 2
57
+ expect(info[:pending]).to be_zero
58
+ expect(info[:status]).to eq 'failed'
59
+ end
60
+ end
61
+ end
62
+
63
+ context 'feature with pending scenario' do
64
+ let :scenarios do
65
+ # Feature: Fuga (passed:1 failed:0, pending:1)
66
+ ['passed', 'pending'].map do |status|
67
+ scenario = base_scenario.dup
68
+ scenario.stub(:status).and_return(status)
69
+ scenario
70
+ end
71
+ end
72
+
73
+ describe '#feature_analysis' do
74
+ it 'should get pending feature information' do
75
+ info = statistics.send(:feature_analysis, 'Hago', scenarios)
76
+ expect(info[:name]).to eq 'Hago'
77
+ expect(info[:passed]).to eq 1
78
+ expect(info[:failed]).to be_zero
79
+ expect(info[:pending]).to eq 1
80
+ expect(info[:status]).to eq 'pending'
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/template/tab/speed_statistics'
3
+
4
+ module TurnipFormatter
5
+ class Template
6
+ module Tab
7
+ describe SpeedStatistics do
8
+ include_context 'turnip_formatter scenario setup'
9
+ include_context 'turnip_formatter standard scenario metadata'
10
+
11
+ let :passed_scenarios do
12
+ ([example] * 3).map do |ex|
13
+ TurnipFormatter::Scenario::Pass.new(ex)
14
+ end.each { |s| s.stub(:run_time).and_return(rand) }
15
+ end
16
+
17
+ let :statistics do
18
+ SpeedStatistics.new(passed_scenarios)
19
+ end
20
+
21
+ describe '#build' do
22
+ it 'should get string as HTML table' do
23
+ scenarios = statistics.scenarios
24
+ html = statistics.build
25
+
26
+ scenarios.each do |scenario|
27
+ tag_scenario_name = "<a href=\"\##{scenario.id}\">#{scenario.name}</a>"
28
+ tag_run_time = "<span>#{scenario.run_time}</span>"
29
+ tag_feature_name = "<span>#{scenario.feature_name}</span>"
30
+
31
+ expect_match = [
32
+ '<tr>',
33
+ "<td>#{tag_feature_name}</td>",
34
+ "<td>#{tag_scenario_name}</td>",
35
+ "<td>#{tag_run_time} sec</td>",
36
+ '</tr>'
37
+ ].join('[[:space:]]+')
38
+
39
+ expect(html).to match %r(#{expect_match})
40
+ end
41
+ end
42
+ end
43
+
44
+ describe '#scenarios' do
45
+ it 'should get array of scenario' do
46
+ scenarios = statistics.scenarios
47
+ expect(scenarios).to have(3).elements
48
+
49
+ run_time_list = scenarios.map(&:run_time)
50
+ expect(run_time_list.sort).to eq run_time_list
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/template/tab/tag_statistics'
3
+
4
+ module TurnipFormatter
5
+ class Template
6
+ module Tab
7
+ describe TagStatistics do
8
+ include_context 'turnip_formatter scenario setup'
9
+ include_context 'turnip_formatter standard scenario metadata'
10
+
11
+ let :base_scenario do
12
+ TurnipFormatter::Scenario::Pass.new(example)
13
+ end
14
+
15
+ let :scenarios do
16
+ scenarios = []
17
+
18
+ # | tag | scenarios | passed | failed | pending | status |
19
+ # |-------+-----------+--------+--------+---------+---------|
20
+ # | none | 1 | 1 | 0 | 0 | status |
21
+ # | @bar | 2 | 0 | 1 | 1 | failed |
22
+ # | @foo | 1 | 0 | 1 | 0 | failed |
23
+ # | @hoge | 1 | 1 | 0 | 1 | pending |
24
+
25
+ # Failed scenario have tags @hoge and @fuga
26
+ scenario = base_scenario.dup
27
+ scenario.stub(:tags).and_return(['foo', 'bar'])
28
+ scenario.stub(:status).and_return('failed')
29
+ scenarios << scenario
30
+
31
+ # Passed scenario no have tags
32
+ scenario = base_scenario.dup
33
+ scenario.stub(:tags).and_return([])
34
+ scenario.stub(:status).and_return('passed')
35
+ scenarios << scenario
36
+
37
+ # Passed scenario have tags @hoge
38
+ scenario = base_scenario.dup
39
+ scenario.stub(:tags).and_return(['hoge'])
40
+ scenario.stub(:status).and_return('passed')
41
+ scenarios << scenario
42
+
43
+ # Pending scenario have tags @fuga and @hago
44
+ scenario = base_scenario.dup
45
+ scenario.stub(:tags).and_return(['bar', 'hoge'])
46
+ scenario.stub(:status).and_return('pending')
47
+ scenarios << scenario
48
+ end
49
+
50
+ let :statistics do
51
+ TagStatistics.new(scenarios)
52
+ end
53
+
54
+ describe '#tag_analysis' do
55
+ let :results do
56
+ statistics.send(:tag_analysis)
57
+ end
58
+
59
+ it 'should get results sort by tag name' do
60
+ expect(results.map(&:name)).to eq ['@bar', '@foo', '@hoge', 'turnip']
61
+ end
62
+
63
+ it 'should get count of each status' do
64
+ # @bar
65
+ res = results[0]
66
+ expect([res.passed, res.failed, res.pending]).to eq [0, 1, 1]
67
+ expect(res.status).to eq 'failed'
68
+
69
+ # @foo
70
+ res = results[1]
71
+ expect([res.passed, res.failed, res.pending]).to eq [0, 1, 0]
72
+ expect(res.status).to eq 'failed'
73
+
74
+ # @hoge
75
+ res = results[2]
76
+ expect([res.passed, res.failed, res.pending]).to eq [1, 0, 1]
77
+ expect(res.status).to eq 'pending'
78
+
79
+ # no tags (turnip)
80
+ res = results[3]
81
+ expect([res.passed, res.failed, res.pending]).to eq [1, 0, 0]
82
+ expect(res.status).to eq 'passed'
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ 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.0.6
4
+ version: 0.1.0
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-05-03 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turnip
@@ -106,6 +106,11 @@ files:
106
106
  - LICENSE.txt
107
107
  - README.md
108
108
  - Rakefile
109
+ - images/tab_feature_statistics.png
110
+ - images/tab_speed_statistics.png
111
+ - images/tab_steps.png
112
+ - images/tab_steps_expanding.png
113
+ - images/tab_tag_statistics.png
109
114
  - lib/rspec/core/formatters/turnip_formatter.rb
110
115
  - lib/turnip_formatter.rb
111
116
  - lib/turnip_formatter/ext/turnip/builder.rb
@@ -125,6 +130,9 @@ files:
125
130
  - lib/turnip_formatter/template/step_multiline.rb
126
131
  - lib/turnip_formatter/template/step_outline.rb
127
132
  - lib/turnip_formatter/template/step_source.rb
133
+ - lib/turnip_formatter/template/tab/feature_statistics.rb
134
+ - lib/turnip_formatter/template/tab/speed_statistics.rb
135
+ - lib/turnip_formatter/template/tab/tag_statistics.rb
128
136
  - lib/turnip_formatter/version.rb
129
137
  - spec/examples/README.md
130
138
  - spec/examples/features/battle.feature
@@ -155,6 +163,9 @@ files:
155
163
  - spec/turnip_formatter/template/step_multiline_spec.rb
156
164
  - spec/turnip_formatter/template/step_outline_spec.rb
157
165
  - spec/turnip_formatter/template/step_source_spec.rb
166
+ - spec/turnip_formatter/template/tab/feature_statistics_spec.rb
167
+ - spec/turnip_formatter/template/tab/speed_statistics_spec.rb
168
+ - spec/turnip_formatter/template/tab/tag_statistics_spec.rb
158
169
  - spec/turnip_formatter/template_spec.rb
159
170
  - turnip_formatter.gemspec
160
171
  homepage: https://github.com/gongo/turnip_formatter
@@ -172,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
183
  version: '0'
173
184
  segments:
174
185
  - 0
175
- hash: -759848237600448328
186
+ hash: 835368190807014694
176
187
  required_rubygems_version: !ruby/object:Gem::Requirement
177
188
  none: false
178
189
  requirements:
@@ -181,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
192
  version: '0'
182
193
  segments:
183
194
  - 0
184
- hash: -759848237600448328
195
+ hash: 835368190807014694
185
196
  requirements: []
186
197
  rubyforge_project:
187
198
  rubygems_version: 1.8.23
@@ -218,4 +229,7 @@ test_files:
218
229
  - spec/turnip_formatter/template/step_multiline_spec.rb
219
230
  - spec/turnip_formatter/template/step_outline_spec.rb
220
231
  - spec/turnip_formatter/template/step_source_spec.rb
232
+ - spec/turnip_formatter/template/tab/feature_statistics_spec.rb
233
+ - spec/turnip_formatter/template/tab/speed_statistics_spec.rb
234
+ - spec/turnip_formatter/template/tab/tag_statistics_spec.rb
221
235
  - spec/turnip_formatter/template_spec.rb