turnip_formatter 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/lib/rspec/core/formatters/turnip_formatter.rb +7 -34
  2. data/lib/turnip_formatter/ext/turnip/rspec.rb +2 -0
  3. data/lib/turnip_formatter/printer/index.rb +29 -0
  4. data/lib/turnip_formatter/printer/runtime_error.rb +41 -0
  5. data/lib/turnip_formatter/printer/scenario.rb +20 -0
  6. data/lib/turnip_formatter/printer/step.rb +34 -0
  7. data/lib/turnip_formatter/printer/step_extra_args.rb +21 -0
  8. data/lib/turnip_formatter/printer/tab_feature_statistics.rb +47 -0
  9. data/lib/turnip_formatter/printer/tab_speed_statistics.rb +34 -0
  10. data/lib/turnip_formatter/printer/tab_tag_statistics.rb +72 -0
  11. data/lib/turnip_formatter/printer.rb +34 -0
  12. data/lib/turnip_formatter/template/exception.erb +9 -25
  13. data/lib/turnip_formatter/template/index.erb +65 -0
  14. data/lib/turnip_formatter/template/runtime_exception.erb +16 -0
  15. data/lib/turnip_formatter/template/scenario.erb +9 -8
  16. data/lib/turnip_formatter/template/step.erb +4 -0
  17. data/lib/turnip_formatter/template/tab_feature_statistics.erb +24 -0
  18. data/lib/turnip_formatter/template/tab_speed_statistics.erb +18 -0
  19. data/lib/turnip_formatter/template/tab_tag_statistics.erb +24 -0
  20. data/lib/turnip_formatter/template/turnip_formatter.js +51 -0
  21. data/lib/turnip_formatter/{formatter.scss → template/turnip_formatter.scss} +0 -0
  22. data/lib/turnip_formatter/template.rb +21 -254
  23. data/lib/turnip_formatter/version.rb +1 -1
  24. data/lib/turnip_formatter.rb +1 -1
  25. data/spec/rspec/core/formatters/turnip_formatter_spec.rb +11 -28
  26. data/spec/turnip_formatter/printer/scenario_spec.rb +33 -0
  27. data/spec/turnip_formatter/printer/step_extra_args_spec.rb +32 -0
  28. data/spec/turnip_formatter/printer/step_spec.rb +86 -0
  29. data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +83 -0
  30. data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +51 -0
  31. data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +90 -0
  32. data/spec/turnip_formatter/template_spec.rb +0 -173
  33. data/turnip_formatter.gemspec +2 -0
  34. metadata +63 -14
  35. data/lib/turnip_formatter/formatter.css +0 -205
  36. data/lib/turnip_formatter/template/scenario_tags.erb +0 -5
  37. data/lib/turnip_formatter/template/tab/feature_statistics.rb +0 -78
  38. data/lib/turnip_formatter/template/tab/speed_statistics.rb +0 -61
  39. data/lib/turnip_formatter/template/tab/tag_statistics.rb +0 -101
  40. data/spec/turnip_formatter/template/tab/feature_statistics_spec.rb +0 -87
  41. data/spec/turnip_formatter/template/tab/speed_statistics_spec.rb +0 -56
  42. data/spec/turnip_formatter/template/tab/tag_statistics_spec.rb +0 -88
@@ -0,0 +1,51 @@
1
+ $(function() {
2
+ var scenarioHeader = 'section.scenario header';
3
+ $(scenarioHeader).siblings().hide();
4
+
5
+ /**
6
+ * Step folding/expanding
7
+ */
8
+ $(scenarioHeader).click(function() {
9
+ $(this).siblings().slideToggle();
10
+ });
11
+
12
+ /**
13
+ * All step folding/expanding action
14
+ */
15
+ $('#scenario_display_check').change(function() {
16
+ var steps = $(scenarioHeader).siblings();
17
+
18
+ if (this.checked) {
19
+ steps.slideUp();
20
+ } else {
21
+ steps.slideDown();
22
+ }
23
+ });
24
+
25
+ ["passed", "failed", "pending"].forEach(function(status) {
26
+ $('#' + status + '_check').click(function() {
27
+ if (this.checked) {
28
+ $('.scenario.' + status).show();
29
+ } else {
30
+ $('.scenario.' + status).hide();
31
+ }
32
+ });
33
+ });
34
+
35
+ $(".scenario.passed").hide();
36
+ $(".scenario.pending").hide();
37
+
38
+ /**
39
+ * Tabs
40
+ */
41
+ $('div#main').tabs();
42
+ $('div#speed-statistics a').click(function() {
43
+ $('div#main').tabs("option", "active", 0);
44
+ });
45
+
46
+ $("div#speed-statistics table").tablesorter({
47
+ headers: {
48
+ 1: { sorter: false }
49
+ }
50
+ });
51
+ });
@@ -1,22 +1,28 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require 'erb'
4
- require 'rspec/core/formatters/helpers'
5
- require 'turnip_formatter/template/tab/speed_statistics'
6
- require 'turnip_formatter/template/tab/feature_statistics'
7
- require 'turnip_formatter/template/tab/tag_statistics'
3
+ require 'turnip_formatter/template'
8
4
  require 'sass'
5
+ require 'uglifier'
9
6
 
10
7
  module TurnipFormatter
11
8
  class Template
12
- include ERB::Util
13
- include RSpec::Core::BacktraceFormatter
14
-
15
9
  class << self
16
10
  def add_js(js_string)
17
11
  js_list << js_string
18
12
  end
19
13
 
14
+ def add_js_file(file)
15
+ js_list << Uglifier.compile(File.read(file))
16
+ end
17
+
18
+ def add_scss(scss_string)
19
+ css_list << Sass::Engine.new(scss_string, scss_option).render
20
+ end
21
+
22
+ def add_scss_file(path)
23
+ css_list << Sass::Engine.for_file(path, scss_option).render
24
+ end
25
+
20
26
  def js_render
21
27
  js_list.join("\n")
22
28
  end
@@ -25,10 +31,6 @@ module TurnipFormatter
25
31
  css_list.join("\n")
26
32
  end
27
33
 
28
- def add_scss(scss_string)
29
- css_list << scss_compile(scss_string)
30
- end
31
-
32
34
  def js_list
33
35
  @js_list ||= []
34
36
  end
@@ -37,249 +39,14 @@ module TurnipFormatter
37
39
  @css_list ||= []
38
40
  end
39
41
 
40
- def scss_compile(scss)
41
- Sass::Engine.new(scss, syntax: :scss).render
42
- end
43
- end
44
-
45
- def print_header
46
- <<-EOS
47
- <!DOCTYPE html>
48
- <html>
49
- <head>
50
- <meta charset="UTF-8">
51
- <title>turnip formatter report</title>
52
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
53
- <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
54
- <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.9.1/jquery.tablesorter.min.js"></script>
55
-
56
- <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/smoothness/jquery-ui.css">
57
- <style>
58
- #{File.read(File.dirname(__FILE__) + '/formatter.css')}
59
- #{self.class.css_render}
60
- </style>
61
-
62
- <script>
63
- $(function() {
64
- var scenarioHeader = 'section.scenario header';
65
- $(scenarioHeader).siblings().hide();
66
-
67
- /**
68
- * Step folding/expanding
69
- */
70
- $(scenarioHeader).click(function() {
71
- var steps = $(this).siblings();
72
- steps.slideToggle();
73
- });
74
-
75
- /**
76
- * All step folding/expanding action
77
- */
78
- $('#scenario_display_check').change(function() {
79
- var steps = $(scenarioHeader).siblings();
80
-
81
- if (this.checked) {
82
- steps.slideUp();
83
- } else {
84
- steps.slideDown();
85
- }
86
- });
87
-
88
- ["passed", "failed", "pending"].forEach(function(status) {
89
- $('#' + status + '_check').click(function() {
90
- if (this.checked) {
91
- $('.scenario.' + status).show();
92
- } else {
93
- $('.scenario.' + status).hide();
94
- }
95
- });
96
- });
97
-
98
- $(".scenario.passed").hide();
99
- $(".scenario.pending").hide();
100
-
101
- /**
102
- * Tabs
103
- */
104
- var tab_area = 'div#main';
105
- $(tab_area).tabs();
106
-
107
- $('div#speed-statistics a').click(function() {
108
- $(tab_area).tabs("option", "active", 0);
109
- });
110
-
111
- $("div#speed-statistics table").tablesorter({
112
- headers: {
113
- 1: { sorter: false }
114
- }
115
- });
116
-
117
- #{self.class.js_render}
118
- });
119
- </script>
120
- </head>
121
- <body>
122
- #{print_section_report}
123
- <div id="main" role="main">
124
- <ul>
125
- <li><a href="#steps-statistics">Steps</a></li>
126
- <li><a href="#speed-statistics">Speed Statistics</a></li>
127
- <li><a href="#feature-statistics">Feature Statistics</a></li>
128
- <li><a href="#tag-statistics">Tag Statistics</a></li>
129
- </ul>
130
- EOS
131
- end
132
-
133
- def print_main_header
134
- <<-EOS
135
- <div id="steps-statistics">
136
- <label><input type="checkbox" id="scenario_display_check" checked>step folding</label>
137
- EOS
138
- end
139
-
140
- def print_main_footer(total_count, failed_count, pending_count, total_time)
141
- update_report_js_tmp = '<script type="text/javascript">document.getElementById("%s").innerHTML = "%s";</script>'
142
- update_report_js = ''
143
-
144
- %w{ total_count failed_count pending_count total_time }.each do |key|
145
- update_report_js += update_report_js_tmp % [key, eval(key)]
146
- end
147
-
148
- "#{update_report_js}</div>"
149
- end
150
-
151
- def print_tab_speed_statsitics(passed_scenarios)
152
- statistics = TurnipFormatter::Template::Tab::SpeedStatistics.new(passed_scenarios)
153
- <<-EOS
154
- <div id="speed-statistics">
155
- <em>Ranking of running time of each <strong>successfully</strong> scenario:</em>
156
- #{statistics.build}
157
- </div>
158
- EOS
159
- end
160
-
161
- def print_tab_feature_statsitics(scenarios)
162
- statistics = TurnipFormatter::Template::Tab::FeatureStatistics.new(scenarios)
163
- <<-EOS
164
- <div id="feature-statistics">
165
- <em>The results for the feature:</em>
166
- #{statistics.build}
167
- </div>
168
- EOS
169
- end
170
-
171
- def print_tab_tag_statsitics(scenarios)
172
- statistics = TurnipFormatter::Template::Tab::TagStatistics.new(scenarios)
173
- <<-EOS
174
- <div id="tag-statistics">
175
- <em>The results for the tab:</em>
176
- #{statistics.build}
177
- </div>
178
- EOS
179
- end
180
-
181
- def print_footer
182
- <<-EOS
183
- </div>
184
- <footer>
185
- <p>Generated by <a href="https://rubygems.org/gems/turnip_formatter">turnip_formatter</a> #{TurnipFormatter::VERSION}</p>
186
- <p>Powered by <a href="http://jquery.com/">jQuery</a> 1.9.1, <a href="http://jqueryui.com/">jQuery UI</a> 1.10.2 and <a href="http://mottie.github.io/tablesorter/">tablesorter</a> 2.9.1</p>
187
- </footer>
188
- </body>
189
- </html>
190
- EOS
191
- end
192
-
193
- def print_scenario(scenario)
194
- render_template(:scenario, { scenario: scenario })
195
- end
196
-
197
- def print_runtime_error(example, exception)
198
- exception.set_backtrace(format_backtrace(exception.backtrace))
199
- render_template(:exception, { example: example, exception: exception })
200
- end
201
-
202
- def print_exception_backtrace(e)
203
- render_template(:exception_backtrace, { backtrace: e.backtrace })
204
- end
205
-
206
- def print_scenario_tags(scenario)
207
- if scenario.tags.empty?
208
- ''
209
- else
210
- render_template(:scenario_tags, { tags: scenario.tags })
211
- end
212
- end
213
-
214
- def print_step_extra_args(extra_args)
215
- extra_args.map do |arg|
216
- if arg.instance_of?(Turnip::Table)
217
- print_step_outline(arg)
218
- else
219
- print_step_multiline(arg)
220
- end
221
- end.join("\n")
222
- end
223
-
224
- def print_step_outline(table)
225
- render_template(:step_outline, { table: table.to_a })
226
- end
227
-
228
- def print_step_multiline(lines)
229
- render_template(:step_multiline, { lines: lines })
230
- end
231
-
232
- def print_section_report
233
- render_template(:section_report)
234
- end
235
-
236
- private
237
-
238
- def step_attr(step)
239
- attr = 'step'
240
- attr += " #{step.status}" if step.attention?
241
- "class=\"#{h(attr)}\""
242
- end
243
-
244
- def step_args(step)
245
- output = []
246
-
247
- step.docs.each do |style, template|
248
- if style == :extra_args
249
- output << print_step_extra_args(template[:value])
250
- else
251
- output << template[:klass].build(template[:value])
252
- end
253
- end
254
-
255
- output.join("\n")
256
- end
257
-
258
- #
259
- # @example
260
- # render_template(:main, { name: 'user' })
261
- # # => ERB.new('/path/to/main.erb') render { name: 'user' }
262
- #
263
- def render_template(name, params = {})
264
- render_template_list(name).result(template_params_binding(params))
265
- end
266
-
267
- def render_template_list(name)
268
- if templates[name].nil?
269
- path = File.dirname(__FILE__) + "/template/#{name.to_s}.erb"
270
- templates[name] = ERB.new(File.read(path))
42
+ def scss_option
43
+ { syntax: :scss, style: :compressed }
271
44
  end
272
-
273
- templates[name]
274
- end
275
-
276
- def template_params_binding(params)
277
- code = params.keys.map { |k| "#{k} = params[#{k.inspect}];" }.join
278
- eval(code + ";binding")
279
- end
280
-
281
- def templates
282
- @templates ||= {}
283
45
  end
284
46
  end
285
47
  end
48
+
49
+ (File.dirname(__FILE__) + '/template').tap do |dirname|
50
+ TurnipFormatter::Template.add_scss_file(dirname + '/turnip_formatter.scss')
51
+ TurnipFormatter::Template.add_js_file(dirname + '/turnip_formatter.js')
52
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module TurnipFormatter
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -9,7 +9,7 @@ module TurnipFormatter
9
9
  require 'turnip_formatter/step_template'
10
10
  require 'turnip_formatter/ext/turnip/rspec'
11
11
  require 'turnip_formatter/ext/turnip/builder'
12
+ require 'turnip_formatter/printer/index'
12
13
  end
13
14
 
14
15
  RSpecTurnipFormatter = RSpec::Core::Formatters::TurnipFormatter
15
-
@@ -10,29 +10,17 @@ module RSpec::Core::Formatters
10
10
  let(:output) { StringIO.new }
11
11
  let(:formatter) { TurnipFormatter.new(output) }
12
12
 
13
- describe '#start' do
14
- it 'should be output header section' do
15
- formatter.start(0)
16
- expect(output.string).to match '<!DOCTYPE html>'
17
- expect(output.string).to match '<div id="main" role="main">'
18
- end
19
- end
20
-
21
13
  describe '#example_passed' do
22
14
  before do
23
15
  scenario.example('passed', metadata) { expect(true).to be_true }
24
16
  feature.run(formatter)
25
17
  end
26
18
 
27
- it 'should be output passed scenario section' do
28
- string = output.string
29
- expect(string).to match 'class="scenario passed"'
30
- end
31
-
32
19
  it 'should get passed scenario count' do
33
20
  expect(formatter.passed_scenarios).to have(1).elements
34
21
  expect(formatter.failed_scenarios).to have(0).elements
35
22
  expect(formatter.pending_scenarios).to have(0).elements
23
+ expect(formatter.scenarios).to have(1).elements
36
24
  end
37
25
  end
38
26
 
@@ -49,14 +37,11 @@ module RSpec::Core::Formatters
49
37
  feature.run(formatter)
50
38
  end
51
39
 
52
- it 'should be output failed scenario section' do
53
- expect(output.string).to match 'class="scenario failed"'
54
- end
55
-
56
40
  it 'should get failed scenario count' do
57
41
  expect(formatter.passed_scenarios).to have(0).elements
58
42
  expect(formatter.failed_scenarios).to have(1).elements
59
43
  expect(formatter.pending_scenarios).to have(0).elements
44
+ expect(formatter.scenarios).to have(1).elements
60
45
  end
61
46
  end
62
47
 
@@ -68,27 +53,25 @@ module RSpec::Core::Formatters
68
53
  feature.run(formatter)
69
54
  end
70
55
 
71
- it 'should be output pending scenario section' do
72
- expect(output.string).to match 'class="scenario pending"'
73
- end
74
-
75
56
  it 'should get pending scenario count' do
76
57
  expect(formatter.passed_scenarios).to have(0).elements
77
58
  expect(formatter.failed_scenarios).to have(0).elements
78
59
  expect(formatter.pending_scenarios).to have(1).elements
60
+ expect(formatter.scenarios).to have(1).elements
79
61
  end
80
62
  end
81
63
 
82
64
  describe '#dump_summary' do
83
- it 'should be output summary section' do
65
+ before do
84
66
  formatter.dump_summary(0.0, 3, 2, 1)
85
- actual = output.string
67
+ end
68
+
69
+ subject { output.string }
86
70
 
87
- expect(actual).to match %r{getElementById\("total_count"\).innerHTML = "3";}
88
- expect(actual).to match %r{getElementById\("failed_count"\).innerHTML = "2";}
89
- expect(actual).to match %r{getElementById\("pending_count"\).innerHTML = "1";}
90
- expect(actual).to match %r{getElementById\("total_time"\).innerHTML = "0.0";}
91
- expect(actual).to match '</html>'
71
+ it 'should be output summary section' do
72
+ should include '(<span id="failed_count">2</span> failed'
73
+ should include '<span id="pending_count">1</span> pending)'
74
+ should include '<span id="total_time">0.0</span>'
92
75
  end
93
76
  end
94
77
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/printer/scenario'
3
+
4
+ module TurnipFormatter::Printer
5
+ describe Scenario do
6
+ include_context 'turnip_formatter scenario setup'
7
+ include_context 'turnip_formatter standard scenario metadata'
8
+
9
+ let(:scenario) do
10
+ TurnipFormatter::Scenario::Pass.new(example)
11
+ end
12
+
13
+ context 'turnip example' do
14
+ describe '.print_out' do
15
+ subject { Scenario.print_out(scenario) }
16
+
17
+ it { should include "<a href=\"##{scenario.id}\">" } # scenario.id
18
+ it { should include 'Scenario: Scenario' } # h(scenario.name)
19
+ end
20
+ end
21
+
22
+ context 'not turnip example' do
23
+ describe '.print_out' do
24
+ before do
25
+ scenario.stub(:validation) { raise NoFeatureFileError }
26
+ RuntimeError.should_receive(:print_out)
27
+ end
28
+
29
+ it { Scenario.print_out(scenario) }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/printer/step_extra_args'
3
+
4
+ module TurnipFormatter::Printer
5
+ describe StepExtraArgs do
6
+ context 'Turnip::Table' do
7
+ describe '.print_out' do
8
+ let(:string) do
9
+ ::Turnip::Table.new([
10
+ ["State", "Money"],
11
+ ["<Tokushima>", "555"],
12
+ ["<Okinawa>", "368"]
13
+ ])
14
+ end
15
+
16
+ subject { StepExtraArgs.print_out([string]) }
17
+
18
+ it { should match %r{<td>State</td>[[:space:]]+<td>Money</td>} }
19
+ it { should match %r{<td>&lt;Tokushima&gt;</td>[[:space:]]+<td>555</td>} }
20
+ it { should match %r{<td>&lt;Okinawa&gt;</td>[[:space:]]+<td>368</td>} }
21
+ end
22
+ end
23
+
24
+ context 'String' do
25
+ describe '.print_out' do
26
+ let(:string) { 'a<a>a' }
27
+ subject { StepExtraArgs.print_out([string]) }
28
+ it { should include '<pre class="multiline">a&lt;a&gt;a</pre>' }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/printer/step'
3
+
4
+ module TurnipFormatter::Printer
5
+ describe Step do
6
+ let(:exception_style) { ::TurnipFormatter::StepTemplate::Exception }
7
+ let(:source_style) { ::TurnipFormatter::StepTemplate::Source }
8
+
9
+ subject { Step.print_out(step) }
10
+
11
+ context 'Step has arguments' do
12
+ let(:table) { Turnip::Table.new [] }
13
+
14
+ context 'original template' do
15
+ describe '#step_args' do
16
+ let(:step) do
17
+ docs = {}
18
+ docs[:extra_args] = { klass: nil, value: ['a', table] }
19
+ docs[source_style] = { klass: source_style, value: 'b' }
20
+ docs[exception_style] = { klass: exception_style, value: 'c' }
21
+
22
+ double(status: '', name: 'step', docs: docs)
23
+ end
24
+
25
+ before do
26
+ StepExtraArgs.should_receive(:print_out).with(['a', table]).and_return('extra_args')
27
+ source_style.should_receive(:build).with('b').and_return('source')
28
+ exception_style.should_receive(:build).with('c').and_return('exception')
29
+ end
30
+
31
+ it { should include "<div class=\"args\">extra_args\nsource\nexception</div>" }
32
+ end
33
+ end
34
+
35
+ context 'custom template' do
36
+ describe '#step_args' do
37
+ let(:custom_template_1) do
38
+ Module.new do
39
+ def self.build(value)
40
+ "<html>#{value}</html>"
41
+ end
42
+ end
43
+ end
44
+
45
+ let(:custom_template_2) do
46
+ Module.new do
47
+ def self.build(value)
48
+ "<strong>#{value}</strong>"
49
+ end
50
+ end
51
+ end
52
+
53
+ let(:step) do
54
+ docs = {
55
+ source: { klass: custom_template_1, value: 'aiueo' },
56
+ exception: { klass: custom_template_2, value: '12345' }
57
+ }
58
+
59
+ double(status: '', name: 'step', docs: docs)
60
+ end
61
+
62
+ it 'should call corresponding method in step' do
63
+ should include "<div class=\"args\"><html>aiueo</html>\n<strong>12345</strong></div>"
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'Step has no argument' do
70
+ describe '#step_args' do
71
+ let(:step) do
72
+ double(status: '', name: 'step', docs: [])
73
+ end
74
+
75
+ before do
76
+ StepExtraArgs.should_not_receive(:print_out)
77
+ source_style.should_not_receive(:build)
78
+ exception_style.should_not_receive(:build)
79
+ end
80
+
81
+ it { should include '<div class="args"></div>' }
82
+ end
83
+ end
84
+ end
85
+ end
86
+
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/printer/tab_feature_statistics'
3
+
4
+ module TurnipFormatter::Printer
5
+ describe TabFeatureStatistics do
6
+ include_context 'turnip_formatter scenario setup'
7
+ include_context 'turnip_formatter standard scenario metadata'
8
+
9
+ let :base_scenario do
10
+ TurnipFormatter::Scenario::Pass.new(example)
11
+ end
12
+
13
+ let :statistics do
14
+ TurnipFormatter::Printer::TabFeatureStatistics
15
+ end
16
+
17
+ context 'feature only passed scenario' do
18
+ let :scenarios do
19
+ # Feature: Hago (passed:2 failed:0, pending:0)
20
+ ['passed', 'passed'].map do |status|
21
+ scenario = base_scenario.dup
22
+ scenario.stub(:status).and_return(status)
23
+ scenario
24
+ end
25
+ end
26
+
27
+ describe '.feature_analysis' do
28
+ it 'should get passed feature information' do
29
+ info = statistics.send(:feature_analysis, 'Hoge', scenarios)
30
+ expect(info.name).to eq 'Hoge'
31
+ expect(info.passed).to eq 2
32
+ expect(info.failed).to be_zero
33
+ expect(info.pending).to be_zero
34
+ expect(info.status).to eq 'passed'
35
+ end
36
+ end
37
+ end
38
+
39
+ context 'feature with failed scenario' do
40
+ let :scenarios do
41
+ # Feature: Hoge (passed:1 failed:2, pending:0)
42
+ ['passed', 'failed', 'failed'].map do |status|
43
+ scenario = base_scenario.dup
44
+ scenario.stub(:status).and_return(status)
45
+ scenario
46
+ end
47
+ end
48
+
49
+ describe '.feature_analysis' do
50
+ it 'should get failed feature information' do
51
+ info = statistics.send(:feature_analysis, 'Fuga', scenarios)
52
+ expect(info.name).to eq 'Fuga'
53
+ expect(info.passed).to eq 1
54
+ expect(info.failed).to eq 2
55
+ expect(info.pending).to be_zero
56
+ expect(info.status).to eq 'failed'
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'feature with pending scenario' do
62
+ let :scenarios do
63
+ # Feature: Fuga (passed:1 failed:0, pending:1)
64
+ ['passed', 'pending'].map do |status|
65
+ scenario = base_scenario.dup
66
+ scenario.stub(:status).and_return(status)
67
+ scenario
68
+ end
69
+ end
70
+
71
+ describe '.feature_analysis' do
72
+ it 'should get pending feature information' do
73
+ info = statistics.send(:feature_analysis, 'Hago', scenarios)
74
+ expect(info.name).to eq 'Hago'
75
+ expect(info.passed).to eq 1
76
+ expect(info.failed).to be_zero
77
+ expect(info.pending).to eq 1
78
+ expect(info.status).to eq 'pending'
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end