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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Rakefile +3 -2
  4. data/lib/rspec/core/formatters/turnip_formatter.rb +8 -9
  5. data/lib/turnip_formatter/ext/turnip/rspec.rb +6 -5
  6. data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.css +1 -1
  7. data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.js +0 -0
  8. data/lib/turnip_formatter/{template → renderer/html/assets}/turnip_formatter.scss +1 -1
  9. data/lib/turnip_formatter/renderer/html/base.rb +4 -4
  10. data/lib/turnip_formatter/renderer/html/index.rb +83 -0
  11. data/lib/turnip_formatter/renderer/html/runtime_error.rb +20 -0
  12. data/lib/turnip_formatter/renderer/html/scenario.rb +20 -0
  13. data/lib/turnip_formatter/renderer/html/statistics_feature.rb +45 -0
  14. data/lib/turnip_formatter/renderer/html/statistics_speed.rb +39 -0
  15. data/lib/turnip_formatter/renderer/html/statistics_tag.rb +53 -0
  16. data/lib/turnip_formatter/renderer/html/views/index.html.erb +94 -0
  17. data/lib/turnip_formatter/renderer/html/views/runtime_error.html.erb +20 -0
  18. data/lib/turnip_formatter/renderer/html/views/scenario.html.erb +23 -0
  19. data/lib/turnip_formatter/renderer/html/views/statistics_feature.html.erb +24 -0
  20. data/lib/turnip_formatter/renderer/html/views/statistics_speed.html.erb +24 -0
  21. data/lib/turnip_formatter/renderer/html/views/statistics_tag.html.erb +24 -0
  22. data/lib/turnip_formatter/renderer/html.rb +84 -0
  23. data/lib/turnip_formatter/resource/scenario/base.rb +80 -0
  24. data/lib/turnip_formatter/resource/scenario/failure.rb +50 -0
  25. data/lib/turnip_formatter/resource/scenario/pass.rb +10 -0
  26. data/lib/turnip_formatter/resource/scenario/pending.rb +42 -0
  27. data/lib/turnip_formatter/version.rb +1 -1
  28. data/lib/turnip_formatter.rb +8 -4
  29. data/test/helper.rb +64 -12
  30. data/test/turnip_formatter/renderer/html/test_index.rb +102 -0
  31. data/test/turnip_formatter/renderer/html/test_runtime_error.rb +40 -0
  32. data/test/turnip_formatter/renderer/html/test_statistics_feature.rb +102 -0
  33. data/test/turnip_formatter/renderer/html/test_statistics_speed.rb +77 -0
  34. data/test/turnip_formatter/renderer/html/test_statistics_tag.rb +112 -0
  35. data/test/turnip_formatter/renderer/html/test_step.rb +27 -0
  36. data/test/turnip_formatter/renderer/test_html.rb +75 -0
  37. data/test/turnip_formatter/resource/scenario/test_failure.rb +39 -0
  38. data/test/turnip_formatter/resource/scenario/test_pass.rb +65 -0
  39. data/test/turnip_formatter/resource/scenario/test_pending.rb +39 -0
  40. data/turnip_formatter.gemspec +1 -1
  41. metadata +45 -57
  42. data/lib/turnip_formatter/printer/index.rb +0 -26
  43. data/lib/turnip_formatter/printer/runtime_error.rb +0 -36
  44. data/lib/turnip_formatter/printer/scenario.rb +0 -22
  45. data/lib/turnip_formatter/printer/tab_feature_statistics.rb +0 -46
  46. data/lib/turnip_formatter/printer/tab_speed_statistics.rb +0 -35
  47. data/lib/turnip_formatter/printer/tab_tag_statistics.rb +0 -76
  48. data/lib/turnip_formatter/printer.rb +0 -29
  49. data/lib/turnip_formatter/scenario/base.rb +0 -99
  50. data/lib/turnip_formatter/scenario/failure.rb +0 -44
  51. data/lib/turnip_formatter/scenario/pass.rb +0 -8
  52. data/lib/turnip_formatter/scenario/pending.rb +0 -40
  53. data/lib/turnip_formatter/step.rb +0 -23
  54. data/lib/turnip_formatter/template/exception.slim +0 -8
  55. data/lib/turnip_formatter/template/index.slim +0 -86
  56. data/lib/turnip_formatter/template/runtime_exception.slim +0 -13
  57. data/lib/turnip_formatter/template/scenario.slim +0 -15
  58. data/lib/turnip_formatter/template/tab_feature_statistics.slim +0 -18
  59. data/lib/turnip_formatter/template/tab_speed_statistics.slim +0 -16
  60. data/lib/turnip_formatter/template/tab_tag_statistics.slim +0 -18
  61. data/spec/turnip_formatter/printer/index_spec.rb +0 -38
  62. data/spec/turnip_formatter/printer/scenario_spec.rb +0 -42
  63. data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +0 -80
  64. data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +0 -48
  65. data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +0 -103
  66. data/spec/turnip_formatter/scenario/base_spec.rb +0 -67
  67. data/spec/turnip_formatter/scenario/failure_spec.rb +0 -55
  68. data/spec/turnip_formatter/scenario/pending_spec.rb +0 -51
  69. data/spec/turnip_formatter/template_spec.rb +0 -119
  70. data/test/sample.feature +0 -16
@@ -34,5 +34,32 @@ module TurnipFormatter::Renderer::Html
34
34
  assert_not_nil(document.at_css('div.step-body'))
35
35
  end
36
36
  end
37
+
38
+ private
39
+
40
+ def sample_step
41
+ sample_feature.scenarios[0].steps[0]
42
+ end
43
+
44
+ def sample_step_with_docstring
45
+ sample_feature.scenarios[0].steps[1]
46
+ end
47
+
48
+ def sample_feature
49
+ feature_build(feature_text)
50
+ end
51
+
52
+ def feature_text
53
+ <<-EOS
54
+ Feature: Feature
55
+
56
+ Scenario: Scenario
57
+ When step
58
+ When step with DocString
59
+ """
60
+ DocString
61
+ """
62
+ EOS
63
+ end
37
64
  end
38
65
  end
@@ -0,0 +1,75 @@
1
+ require 'helper'
2
+ require 'tempfile'
3
+ require 'turnip_formatter/renderer/html'
4
+
5
+ module TurnipFormatter::Renderer
6
+ class TestHtml < Test::Unit::TestCase
7
+ def setup
8
+ Html.reset!
9
+
10
+ Html.add_javascript(@script_path)
11
+ Html.add_stylesheet(@style_path)
12
+ end
13
+
14
+ def teardown
15
+ Html.reset!
16
+ end
17
+
18
+ sub_test_case 'with local file' do
19
+ def setup
20
+ @script_path = Tempfile.open(['local', 'js']) do |f|
21
+ f.write('var s = 1 + 1')
22
+ f.path
23
+ end
24
+
25
+ @style_path = Tempfile.open(['local', 'css']) do |f|
26
+ f.write('body { }')
27
+ f.path
28
+ end
29
+
30
+ super
31
+ end
32
+
33
+ def test_render_javascript_codes
34
+ assert_match(/#{Regexp.escape('var s = 1 + 1')}/, Html.render_javascript_codes)
35
+ end
36
+
37
+ def test_render_javascript_links
38
+ assert Html.render_javascript_links.empty?
39
+ end
40
+
41
+ def test_render_stylesheet_codes
42
+ assert_match(/#{Regexp.escape('body { }')}/, Html.render_stylesheet_codes)
43
+ end
44
+
45
+ def test_render_stylesheet_links
46
+ assert Html.render_stylesheet_links.empty?
47
+ end
48
+ end
49
+
50
+ sub_test_case 'with remote file' do
51
+ def setup
52
+ @script_path = 'http://example.com/foo.js'
53
+ @style_path = 'http://example.com/foo.css'
54
+
55
+ super
56
+ end
57
+
58
+ def test_render_javascript_codes
59
+ assert Html.render_javascript_codes.empty?
60
+ end
61
+
62
+ def test_render_javascript_links
63
+ assert_match(/#{Regexp.escape('http://example.com/foo.js')}/, Html.render_javascript_links)
64
+ end
65
+
66
+ def test_render_stylesheet_codes
67
+ assert Html.render_stylesheet_codes.empty?
68
+ end
69
+
70
+ def test_render_stylesheet_links
71
+ assert_match(/#{Regexp.escape('http://example.com/foo.css')}/, Html.render_stylesheet_links)
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+ require 'turnip_formatter/resource/scenario/failure'
3
+
4
+ module TurnipFormatter::Resource::Scenario
5
+ class TestFailure < Test::Unit::TestCase
6
+ include TurnipFormatter::TestHelper
7
+
8
+ def setup
9
+ @resource = Failure.new(scenario_example)
10
+ end
11
+
12
+ def test_status
13
+ assert_equal(:failed, @resource.status)
14
+ end
15
+
16
+ def test_steps
17
+ expect = [:passed, :failed, :unexecute]
18
+ actual = @resource.steps.map(&:status)
19
+
20
+ assert_equal(expect, actual)
21
+ end
22
+
23
+ private
24
+
25
+ def scenario_example
26
+ @@scenario_example ||= (
27
+ feature = feature_build(<<-EOS)
28
+ Feature: A simple feature
29
+ Scenario: This is a simple feature
30
+ When I attack it
31
+ Then [ERROR] it should die
32
+ And I get drop items
33
+ EOS
34
+
35
+ run_feature(feature, '/path/to/test.feature').first
36
+ )
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,65 @@
1
+ require 'helper'
2
+ require 'turnip_formatter/resource/scenario/pass'
3
+
4
+ module TurnipFormatter::Resource::Scenario
5
+ class TestPass < Test::Unit::TestCase
6
+ include TurnipFormatter::TestHelper
7
+
8
+ def setup
9
+ @resource = Pass.new(scenario_example)
10
+ end
11
+
12
+ def test_steps
13
+ assert_equal(4, @resource.steps.size)
14
+ end
15
+
16
+ def test_id
17
+ assert_match(/^scenario_/, @resource.id)
18
+ end
19
+
20
+ def test_status
21
+ assert_equal(:passed, @resource.status)
22
+ end
23
+
24
+ def test_feature_info
25
+ assert_equal('"A simple feature" in /path/to/test.feature', @resource.feature_info)
26
+ end
27
+
28
+ def test_run_time
29
+ assert_equal(Float, @resource.run_time.class)
30
+ end
31
+
32
+ def test_backgrounds
33
+ assert_equal(1, @resource.backgrounds.size)
34
+ assert_equal(2, @resource.backgrounds.first.steps.size)
35
+ end
36
+
37
+ def test_tags
38
+ assert_equal(['feature_tag', 'scenario_tag'], @resource.tags)
39
+ end
40
+
41
+ private
42
+
43
+ def scenario_example
44
+ @@scenario_example ||= (
45
+ feature = feature_build(<<-EOS)
46
+
47
+ @feature_tag
48
+ Feature: A simple feature
49
+
50
+ Background:
51
+ Given there is a monster
52
+ And I have a sword
53
+
54
+ @scenario_tag
55
+ Scenario: This is a simple feature
56
+ When I attack it
57
+ Then it should die
58
+
59
+ EOS
60
+
61
+ run_feature(feature, '/path/to/test.feature').first
62
+ )
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+ require 'turnip_formatter/resource/scenario/pending'
3
+
4
+ module TurnipFormatter::Resource::Scenario
5
+ class TestPending < Test::Unit::TestCase
6
+ include TurnipFormatter::TestHelper
7
+
8
+ def setup
9
+ @resource = Pending.new(scenario_example)
10
+ end
11
+
12
+ def test_status
13
+ assert_equal(:pending, @resource.status)
14
+ end
15
+
16
+ def test_steps
17
+ expect = [:passed, :pending, :unexecute]
18
+ actual = @resource.steps.map(&:status)
19
+
20
+ assert_equal(expect, actual)
21
+ end
22
+
23
+ private
24
+
25
+ def scenario_example
26
+ @@scenario_example ||= (
27
+ feature = feature_build(<<-EOS)
28
+ Feature: A simple feature
29
+ Scenario: This is a simple feature
30
+ When I attack it
31
+ Then [PENDING] it should die
32
+ And I get drop items
33
+ EOS
34
+
35
+ run_feature(feature, '/path/to/test.feature').first
36
+ )
37
+ end
38
+ end
39
+ end
@@ -20,13 +20,13 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'turnip', '~> 3.0.0.pre.beta.4'
22
22
  spec.add_dependency 'slim'
23
- spec.add_dependency 'tilt'
24
23
  spec.add_dependency 'rspec', [">=3.0", "<3.5"]
25
24
 
26
25
  # For ruby >= 2.1
27
26
  spec.add_dependency 'activesupport', '~> 4.2.7'
28
27
 
29
28
  spec.add_development_dependency 'test-unit'
29
+ spec.add_development_dependency 'test-unit-rr'
30
30
  spec.add_development_dependency 'bundler', '~> 1.3'
31
31
  spec.add_development_dependency 'rake'
32
32
  spec.add_development_dependency 'coveralls'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turnip_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.pre.beta.2
4
+ version: 0.6.0.pre.beta.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wataru MIYAGUNI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-13 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turnip
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: tilt
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +86,20 @@ dependencies:
100
86
  - - ">="
101
87
  - !ruby/object:Gem::Version
102
88
  version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: test-unit-rr
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: bundler
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -223,63 +223,60 @@ files:
223
223
  - lib/rspec/core/formatters/turnip_formatter.rb
224
224
  - lib/turnip_formatter.rb
225
225
  - lib/turnip_formatter/ext/turnip/rspec.rb
226
- - lib/turnip_formatter/printer.rb
227
- - lib/turnip_formatter/printer/index.rb
228
- - lib/turnip_formatter/printer/runtime_error.rb
229
- - lib/turnip_formatter/printer/scenario.rb
230
- - lib/turnip_formatter/printer/tab_feature_statistics.rb
231
- - lib/turnip_formatter/printer/tab_speed_statistics.rb
232
- - lib/turnip_formatter/printer/tab_tag_statistics.rb
226
+ - lib/turnip_formatter/renderer/html.rb
227
+ - lib/turnip_formatter/renderer/html/assets/turnip_formatter.css
228
+ - lib/turnip_formatter/renderer/html/assets/turnip_formatter.js
229
+ - lib/turnip_formatter/renderer/html/assets/turnip_formatter.scss
233
230
  - lib/turnip_formatter/renderer/html/base.rb
234
231
  - lib/turnip_formatter/renderer/html/data_table.rb
235
232
  - lib/turnip_formatter/renderer/html/doc_string.rb
233
+ - lib/turnip_formatter/renderer/html/index.rb
234
+ - lib/turnip_formatter/renderer/html/runtime_error.rb
235
+ - lib/turnip_formatter/renderer/html/scenario.rb
236
+ - lib/turnip_formatter/renderer/html/statistics_feature.rb
237
+ - lib/turnip_formatter/renderer/html/statistics_speed.rb
238
+ - lib/turnip_formatter/renderer/html/statistics_tag.rb
236
239
  - lib/turnip_formatter/renderer/html/step.rb
237
240
  - lib/turnip_formatter/renderer/html/views/data_table.html.erb
238
241
  - lib/turnip_formatter/renderer/html/views/doc_string.html.erb
242
+ - lib/turnip_formatter/renderer/html/views/index.html.erb
243
+ - lib/turnip_formatter/renderer/html/views/runtime_error.html.erb
244
+ - lib/turnip_formatter/renderer/html/views/scenario.html.erb
245
+ - lib/turnip_formatter/renderer/html/views/statistics_feature.html.erb
246
+ - lib/turnip_formatter/renderer/html/views/statistics_speed.html.erb
247
+ - lib/turnip_formatter/renderer/html/views/statistics_tag.html.erb
239
248
  - lib/turnip_formatter/renderer/html/views/step.html.erb
249
+ - lib/turnip_formatter/resource/scenario/base.rb
250
+ - lib/turnip_formatter/resource/scenario/failure.rb
251
+ - lib/turnip_formatter/resource/scenario/pass.rb
252
+ - lib/turnip_formatter/resource/scenario/pending.rb
240
253
  - lib/turnip_formatter/resource/step.rb
241
- - lib/turnip_formatter/scenario/base.rb
242
- - lib/turnip_formatter/scenario/failure.rb
243
- - lib/turnip_formatter/scenario/pass.rb
244
- - lib/turnip_formatter/scenario/pending.rb
245
- - lib/turnip_formatter/step.rb
246
254
  - lib/turnip_formatter/step_template/base.rb
247
255
  - lib/turnip_formatter/step_template/exception.rb
248
256
  - lib/turnip_formatter/step_template/exception.slim
249
257
  - lib/turnip_formatter/step_template/source.rb
250
258
  - lib/turnip_formatter/template.rb
251
- - lib/turnip_formatter/template/exception.slim
252
- - lib/turnip_formatter/template/index.slim
253
- - lib/turnip_formatter/template/runtime_exception.slim
254
- - lib/turnip_formatter/template/scenario.slim
255
- - lib/turnip_formatter/template/tab_feature_statistics.slim
256
- - lib/turnip_formatter/template/tab_speed_statistics.slim
257
- - lib/turnip_formatter/template/tab_tag_statistics.slim
258
- - lib/turnip_formatter/template/turnip_formatter.css
259
- - lib/turnip_formatter/template/turnip_formatter.js
260
- - lib/turnip_formatter/template/turnip_formatter.scss
261
259
  - lib/turnip_formatter/version.rb
262
260
  - spec/spec_helper.rb
263
261
  - spec/support/example_helper.rb
264
262
  - spec/support/passed.feature
265
263
  - spec/support/step_helper.rb
266
- - spec/turnip_formatter/printer/index_spec.rb
267
- - spec/turnip_formatter/printer/scenario_spec.rb
268
- - spec/turnip_formatter/printer/tab_feature_statistics_spec.rb
269
- - spec/turnip_formatter/printer/tab_speed_statistics_spec.rb
270
- - spec/turnip_formatter/printer/tab_tag_statistics_spec.rb
271
- - spec/turnip_formatter/scenario/base_spec.rb
272
- - spec/turnip_formatter/scenario/failure_spec.rb
273
- - spec/turnip_formatter/scenario/pending_spec.rb
274
264
  - spec/turnip_formatter/step_template/base_spec.rb
275
265
  - spec/turnip_formatter/step_template/exception_spec.rb
276
266
  - spec/turnip_formatter/step_template/source_spec.rb
277
- - spec/turnip_formatter/template_spec.rb
278
267
  - test/helper.rb
279
- - test/sample.feature
280
268
  - test/turnip_formatter/renderer/html/test_data_table.rb
281
269
  - test/turnip_formatter/renderer/html/test_doc_string.rb
270
+ - test/turnip_formatter/renderer/html/test_index.rb
271
+ - test/turnip_formatter/renderer/html/test_runtime_error.rb
272
+ - test/turnip_formatter/renderer/html/test_statistics_feature.rb
273
+ - test/turnip_formatter/renderer/html/test_statistics_speed.rb
274
+ - test/turnip_formatter/renderer/html/test_statistics_tag.rb
282
275
  - test/turnip_formatter/renderer/html/test_step.rb
276
+ - test/turnip_formatter/renderer/test_html.rb
277
+ - test/turnip_formatter/resource/scenario/test_failure.rb
278
+ - test/turnip_formatter/resource/scenario/test_pass.rb
279
+ - test/turnip_formatter/resource/scenario/test_pending.rb
283
280
  - turnip_formatter.gemspec
284
281
  homepage: https://github.com/gongo/turnip_formatter
285
282
  licenses:
@@ -310,15 +307,6 @@ test_files:
310
307
  - spec/support/example_helper.rb
311
308
  - spec/support/passed.feature
312
309
  - spec/support/step_helper.rb
313
- - spec/turnip_formatter/printer/index_spec.rb
314
- - spec/turnip_formatter/printer/scenario_spec.rb
315
- - spec/turnip_formatter/printer/tab_feature_statistics_spec.rb
316
- - spec/turnip_formatter/printer/tab_speed_statistics_spec.rb
317
- - spec/turnip_formatter/printer/tab_tag_statistics_spec.rb
318
- - spec/turnip_formatter/scenario/base_spec.rb
319
- - spec/turnip_formatter/scenario/failure_spec.rb
320
- - spec/turnip_formatter/scenario/pending_spec.rb
321
310
  - spec/turnip_formatter/step_template/base_spec.rb
322
311
  - spec/turnip_formatter/step_template/exception_spec.rb
323
312
  - spec/turnip_formatter/step_template/source_spec.rb
324
- - spec/turnip_formatter/template_spec.rb
@@ -1,26 +0,0 @@
1
- require 'turnip_formatter/printer'
2
- require 'turnip_formatter/printer/scenario'
3
- require 'turnip_formatter/printer/tab_feature_statistics'
4
- require 'turnip_formatter/printer/tab_tag_statistics'
5
- require 'turnip_formatter/printer/tab_speed_statistics'
6
-
7
- module TurnipFormatter
8
- module Printer
9
- class Index
10
- class << self
11
- include TurnipFormatter::Printer
12
-
13
- def print_out(params)
14
- render_template(:index, {
15
- scenarios: params[:scenarios],
16
- failed_count: params[:failed_count],
17
- pending_count: params[:pending_count],
18
- total_time: params[:total_time],
19
- scenario_files: params[:scenario_files]
20
- }
21
- )
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,36 +0,0 @@
1
- require 'turnip_formatter/printer'
2
-
3
- module TurnipFormatter
4
- module Printer
5
- class RuntimeError
6
- class << self
7
- include TurnipFormatter::Printer
8
-
9
- def print_out(example, exception)
10
- render_template(:runtime_exception, {
11
- example: example,
12
- runtime_exception: runtime_exception(exception),
13
- example_exception: example_exception(example),
14
- }
15
- )
16
- end
17
-
18
- private
19
-
20
- def runtime_exception(exception)
21
- render_template(:exception, { title: 'Runtime', exception: exception })
22
- end
23
-
24
- def example_exception(example)
25
- return '' unless example.exception
26
-
27
- render_template(:exception, {
28
- title: 'Example',
29
- exception: example.exception
30
- }
31
- )
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,22 +0,0 @@
1
- require 'turnip_formatter/printer'
2
- require 'turnip_formatter/printer/runtime_error'
3
- require 'turnip_formatter/renderer/html/step'
4
-
5
- module TurnipFormatter
6
- module Printer
7
- class Scenario
8
- class << self
9
- include TurnipFormatter::Printer
10
-
11
- def print_out(scenario)
12
- #
13
- # TODO output for scenario.valid? == false
14
- #
15
- render_template(:scenario, scenario: scenario) if scenario.valid?
16
- rescue => e
17
- TurnipFormatter::Printer::RuntimeError.print_out(scenario.example, e)
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,46 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'turnip_formatter/printer'
4
- require 'ostruct'
5
-
6
- module TurnipFormatter
7
- module Printer
8
- module TabFeatureStatistics
9
- class << self
10
- include TurnipFormatter::Printer
11
-
12
- def print_out(scenarios)
13
- features = scenarios.group_by { |s| s.feature_name }
14
-
15
- results = features.map do |name, feature_scenarios|
16
- feature_analysis(name, feature_scenarios)
17
- end
18
-
19
- render_template(:tab_feature_statistics, { analysis_results: results })
20
- end
21
-
22
- private
23
-
24
- def feature_analysis(name, scenarios)
25
- status_group = scenarios.group_by { |s| s.status }
26
- status_group.default = []
27
-
28
- info = OpenStruct.new(
29
- name: name,
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,
34
- status: 'failed'
35
- )
36
-
37
- if info.failed_count.zero?
38
- info.status = info.pending_count.zero? ? 'passed' : 'pending'
39
- end
40
-
41
- info
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,35 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'turnip_formatter/printer'
4
- require 'ostruct'
5
-
6
- module TurnipFormatter
7
- module Printer
8
- class TabSpeedStatistics
9
- class << self
10
- include TurnipFormatter::Printer
11
-
12
- def print_out(scenarios)
13
- passed_scenarios = scenarios.select { |s| s.status == 'passed' }
14
- results = speed_analysis(passed_scenarios)
15
- render_template(:tab_speed_statistics, { analysis_results: results })
16
- end
17
-
18
- private
19
-
20
- def speed_analysis(scenarios)
21
- scenarios.map do |s|
22
- OpenStruct.new(
23
- {
24
- id: s.id,
25
- feature_name: s.feature_name,
26
- name: s.name,
27
- run_time: s.run_time
28
- }
29
- )
30
- end.sort { |a, b| a.run_time <=> b.run_time }
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,76 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'turnip_formatter/printer'
4
- require 'ostruct'
5
-
6
- module TurnipFormatter
7
- module Printer
8
- class TabTagStatistics
9
- class << self
10
- include TurnipFormatter::Printer
11
-
12
- def print_out(scenarios)
13
- tags = group_by_tag(scenarios)
14
-
15
- results = tags.map do |name, tag_scenarios|
16
- tag_analysis(name, tag_scenarios)
17
- end
18
-
19
- render_template(:tab_tag_statistics, { analysis_results: results })
20
- end
21
-
22
- private
23
-
24
- def tag_analysis(name, scenarios)
25
- status_group = scenarios.group_by { |s| s[:scenario].status }
26
- status_group.default = []
27
-
28
- info = OpenStruct.new(
29
- name: name,
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,
34
- status: 'failed'
35
- )
36
-
37
- if info.failed_count.zero?
38
- info.status = info.pending_count.zero? ? 'passed' : 'pending'
39
- end
40
-
41
- info
42
- end
43
-
44
- #
45
- # Image...
46
- #
47
- # [
48
- # { tags: [:a, :b], val: 3 },
49
- # { tags: [:a], val: 4 },
50
- # { tags: [:b], val: 5 },
51
- # ]
52
- # # => [
53
- # [:a, [3, 4]],
54
- # [:b, [3, 5]],
55
- # ]
56
- #
57
- #
58
- def group_by_tag(scenarios)
59
- scenarios.map do |scenario|
60
- if scenario.valid?
61
- if scenario.tags.empty?
62
- { name: 'turnip', scenario: scenario }
63
- else
64
- scenario.tags.map do |tag|
65
- { name: '@' + tag, scenario: scenario }
66
- end
67
- end
68
- else
69
- { name: 'runtime error', scenario: scenario }
70
- end
71
- end.flatten.group_by { |s| s[:name] }.sort
72
- end
73
- end
74
- end
75
- end
76
- end