turnip_formatter 0.6.0.pre.beta.7 → 0.6.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/lib/turnip_formatter/resource/scenario/base.rb +20 -4
- data/lib/turnip_formatter/resource/scenario/failure.rb +49 -54
- data/lib/turnip_formatter/resource/scenario/pass.rb +3 -3
- data/lib/turnip_formatter/resource/scenario/pending.rb +17 -20
- data/lib/turnip_formatter/resource/step/failure_result.rb +26 -0
- data/lib/turnip_formatter/resource/step/hook.rb +17 -9
- data/lib/turnip_formatter/resource/step/pending_result.rb +19 -0
- data/lib/turnip_formatter/resource/step/step.rb +50 -0
- data/lib/turnip_formatter/version.rb +1 -1
- data/test/helper.rb +26 -2
- data/test/turnip_formatter/renderer/html/test_step.rb +6 -3
- data/test/turnip_formatter/step_template/test_base.rb +54 -0
- data/test/turnip_formatter/step_template/test_exception.rb +33 -0
- data/test/turnip_formatter/step_template/test_source.rb +27 -0
- data/turnip_formatter.gemspec +2 -3
- metadata +28 -41
- data/.rspec +0 -1
- data/Guardfile +0 -9
- data/lib/turnip_formatter/resource/step/base.rb +0 -24
- data/lib/turnip_formatter/resource/step/failure.rb +0 -27
- data/lib/turnip_formatter/resource/step/pass.rb +0 -13
- data/lib/turnip_formatter/resource/step/pending.rb +0 -21
- data/lib/turnip_formatter/resource/step/unexecute.rb +0 -13
- data/spec/spec_helper.rb +0 -25
- data/spec/support/example_helper.rb +0 -57
- data/spec/support/passed.feature +0 -4
- data/spec/support/step_helper.rb +0 -27
- data/spec/turnip_formatter/step_template/base_spec.rb +0 -82
- data/spec/turnip_formatter/step_template/exception_spec.rb +0 -25
- data/spec/turnip_formatter/step_template/source_spec.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 671a78926ca1578069e874dbca23b8fff9514c7b
|
4
|
+
data.tar.gz: d9a95077cd0cde1860a81c21f85e92b5ea63b08d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c488247c66369b917d7864a3e698a5352df9b290557e8ecd45845b75c7e968e774e3fffd12f1877a4f9f4e47721ad384e34fef214f51f60e89479268dfbab109
|
7
|
+
data.tar.gz: e4f32e51de9127547a980f8361930e19a82632971b76a0afb7c3517766ecc2d29ce5b6a79af53502a76bcda7b6fb74b88afb8ba5a5c93d32823752df5ee3e490
|
data/.gitignore
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'forwardable'
|
2
|
-
require 'turnip_formatter/resource/step/
|
3
|
-
require 'turnip_formatter/resource/step/
|
2
|
+
require 'turnip_formatter/resource/step/step'
|
3
|
+
require 'turnip_formatter/resource/step/hook'
|
4
4
|
|
5
5
|
module TurnipFormatter
|
6
6
|
module Resource
|
@@ -53,8 +53,20 @@ module TurnipFormatter
|
|
53
53
|
example.metadata[:turnip_formatter][:feature]
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
|
56
|
+
def steps
|
57
|
+
return @steps if @steps
|
58
|
+
|
59
|
+
@steps = raw_steps.map do |step|
|
60
|
+
TurnipFormatter::Resource::Step::Step.new(example, step)
|
61
|
+
end
|
62
|
+
|
63
|
+
mark_status
|
64
|
+
|
65
|
+
@steps
|
66
|
+
end
|
67
|
+
|
68
|
+
def mark_status
|
69
|
+
raise NotImplementedError
|
58
70
|
end
|
59
71
|
|
60
72
|
private
|
@@ -63,6 +75,10 @@ module TurnipFormatter
|
|
63
75
|
@raw = example.metadata[:turnip_formatter][:scenario]
|
64
76
|
end
|
65
77
|
|
78
|
+
def raw_steps
|
79
|
+
backgrounds.map(&:steps).flatten + raw.steps
|
80
|
+
end
|
81
|
+
|
66
82
|
def feature_file_path
|
67
83
|
example.metadata[:file_path]
|
68
84
|
end
|
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'turnip_formatter/resource/scenario/base'
|
2
|
-
require 'turnip_formatter/resource/step/failure'
|
3
|
-
require 'turnip_formatter/resource/step/hook'
|
4
2
|
require 'rspec/core/formatters/exception_presenter'
|
5
3
|
|
6
4
|
module TurnipFormatter
|
@@ -8,77 +6,74 @@ module TurnipFormatter
|
|
8
6
|
module Scenario
|
9
7
|
class Failure < Base
|
10
8
|
#
|
11
|
-
#
|
9
|
+
# Mark status for each step
|
12
10
|
#
|
13
11
|
# example:
|
14
12
|
#
|
15
13
|
# When foo
|
16
|
-
# And bar
|
17
|
-
#
|
18
|
-
# Then piyo
|
14
|
+
# And bar <= failed line
|
15
|
+
# Then baz
|
19
16
|
#
|
20
|
-
# # => [
|
21
|
-
# # <Step::
|
22
|
-
# # <Step::
|
23
|
-
# # <Step::
|
24
|
-
# # <Step::Unexecute 'piyo'>
|
17
|
+
# # @steps => [
|
18
|
+
# # <Step::Step 'foo'> # .status => :passed
|
19
|
+
# # <Step::Step 'bar'> # .status => :failed
|
20
|
+
# # <Step::Step 'baz'> # .status => :unexecute
|
25
21
|
# # ]
|
26
22
|
#
|
27
|
-
|
23
|
+
# example: aggregate_failures = true
|
24
|
+
#
|
25
|
+
# # @steps => [
|
26
|
+
# # <Step::Step 'foo'> # .status => :passed
|
27
|
+
# # <Step::Step 'bar'> # .status => :failed
|
28
|
+
# # <Step::Step 'baz'> # .status => :passed
|
29
|
+
# # ]
|
30
|
+
#
|
31
|
+
# example: Occurs error in RSpec before hook
|
32
|
+
#
|
33
|
+
# # @steps => [
|
34
|
+
# # <Step::BeforeHook ''> # .status => :failed
|
35
|
+
# # <Step::Step 'foo'> # .status => :unexecute
|
36
|
+
# # <Step::Step 'bar'> # .status => :unexecute
|
37
|
+
# # <Step::Step 'baz'> # .status => :unexecute
|
38
|
+
# # ]
|
39
|
+
#
|
40
|
+
# example: Occurs error in RSpec after hook
|
41
|
+
#
|
42
|
+
# # @steps => [
|
43
|
+
# # <Step::Step 'foo'> # .status => :passed
|
44
|
+
# # <Step::Step 'bar'> # .status => :failed
|
45
|
+
# # <Step::Step 'baz'> # .status => :unexecute
|
46
|
+
# # <Step::AfterHook ''> # .status => :failed
|
47
|
+
# # ]
|
48
|
+
#
|
49
|
+
def mark_status
|
28
50
|
exceptions = all_exception_group_by_line_number
|
29
51
|
|
30
52
|
if exceptions.has_key?(:before)
|
31
|
-
|
53
|
+
before_step = TurnipFormatter::Resource::Step::BeforeHook.new(example)
|
54
|
+
before_step.set_exceptions(exceptions[:before])
|
55
|
+
@steps.unshift(before_step)
|
56
|
+
return
|
32
57
|
end
|
33
58
|
|
34
|
-
steps
|
59
|
+
@steps.each do |step|
|
60
|
+
step.mark_as_executed
|
61
|
+
exs = exceptions[step.line]
|
35
62
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
63
|
+
next unless exs
|
64
|
+
step.set_exceptions(exs)
|
39
65
|
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def steps_with_error(exceptions)
|
46
|
-
step_klass = TurnipFormatter::Resource::Step::Pass
|
47
|
-
|
48
|
-
raw_steps.map do |rs|
|
49
|
-
ex = exceptions[rs.line]
|
50
|
-
next step_klass.new(example, rs) unless ex
|
51
|
-
|
52
|
-
# The status of step after error step is determined by `aggregate_failures` option
|
53
|
-
if example.metadata[:aggregate_failures]
|
54
|
-
step_klass = TurnipFormatter::Resource::Step::Pass
|
55
|
-
else
|
56
|
-
step_klass = TurnipFormatter::Resource::Step::Unexecute
|
57
|
-
end
|
58
|
-
|
59
|
-
TurnipFormatter::Resource::Step::Failure.new(example, rs).tap do |step|
|
60
|
-
step.set_exceptions(ex)
|
61
|
-
end
|
66
|
+
break if !example.metadata[:aggregate_failures]
|
62
67
|
end
|
63
|
-
end
|
64
68
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
after_steps = raw_steps.map do |rs|
|
70
|
-
TurnipFormatter::Resource::Step::Unexecute.new(example, rs)
|
69
|
+
if exceptions.has_key?(:after)
|
70
|
+
after_step = TurnipFormatter::Resource::Step::AfterHook.new(example)
|
71
|
+
after_step.set_exceptions(exceptions[:after])
|
72
|
+
@steps.push(after_step)
|
71
73
|
end
|
72
|
-
|
73
|
-
[before_step] + after_steps
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
after_step = TurnipFormatter::Resource::Step::AfterHook.new(example)
|
78
|
-
after_step.set_exceptions(exceptions)
|
79
|
-
|
80
|
-
steps + [after_step]
|
81
|
-
end
|
76
|
+
private
|
82
77
|
|
83
78
|
def error_in_before_hook?(exceptions)
|
84
79
|
exceptions.has_key?(:before)
|
@@ -4,9 +4,9 @@ module TurnipFormatter
|
|
4
4
|
module Resource
|
5
5
|
module Scenario
|
6
6
|
class Pass < Base
|
7
|
-
def
|
8
|
-
|
9
|
-
|
7
|
+
def mark_status
|
8
|
+
@steps.each do |step|
|
9
|
+
step.mark_as_executed
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,38 +1,35 @@
|
|
1
1
|
require 'turnip_formatter/resource/scenario/base'
|
2
|
-
require 'turnip_formatter/resource/step/pending'
|
3
2
|
|
4
3
|
module TurnipFormatter
|
5
4
|
module Resource
|
6
5
|
module Scenario
|
7
6
|
class Pending < Base
|
8
7
|
#
|
9
|
-
#
|
8
|
+
# Mark status for each step
|
10
9
|
#
|
11
10
|
# example:
|
12
11
|
#
|
13
12
|
# When foo
|
14
|
-
# And bar
|
15
|
-
#
|
16
|
-
# Then piyo
|
13
|
+
# And bar <= pending line
|
14
|
+
# Then baz
|
17
15
|
#
|
18
|
-
# # => [
|
19
|
-
# # <Step::
|
20
|
-
# # <Step::
|
21
|
-
# # <Step::
|
22
|
-
# # <Step::Unexecute 'piyo'>
|
16
|
+
# # @steps => [
|
17
|
+
# # <Step::Step 'foo'> # .status => :passed
|
18
|
+
# # <Step::Step 'bar'> # .status => :pending
|
19
|
+
# # <Step::Step 'baz'> # .status => :unexecute
|
23
20
|
# # ]
|
24
21
|
#
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
klass = TurnipFormatter::Resource::Step::Pass
|
29
|
-
elsif rs.line == pending_line_number
|
30
|
-
klass = TurnipFormatter::Resource::Step::Pending
|
31
|
-
else
|
32
|
-
klass = TurnipFormatter::Resource::Step::Unexecute
|
33
|
-
end
|
22
|
+
def mark_status
|
23
|
+
@steps.each do |step|
|
24
|
+
step.mark_as_executed
|
34
25
|
|
35
|
-
|
26
|
+
if pending_line_number == step.line
|
27
|
+
step.set_pending(
|
28
|
+
example.execution_result.pending_message,
|
29
|
+
example.location
|
30
|
+
)
|
31
|
+
break
|
32
|
+
end
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TurnipFormatter
|
2
|
+
module Resource
|
3
|
+
module Step
|
4
|
+
module FailureResult
|
5
|
+
def failed?
|
6
|
+
!exceptions.empty?
|
7
|
+
end
|
8
|
+
|
9
|
+
def exceptions
|
10
|
+
@exceptions ||= []
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# @param [Array<Exception>] exs
|
15
|
+
#
|
16
|
+
def set_exceptions(exs)
|
17
|
+
if !exs.is_a?(Array)
|
18
|
+
exs = [exs]
|
19
|
+
end
|
20
|
+
|
21
|
+
exceptions.concat(exs)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,9 +1,14 @@
|
|
1
|
+
require 'turnip_formatter/resource/step/failure_result'
|
2
|
+
require 'turnip_formatter/resource/step/pending_result'
|
3
|
+
|
1
4
|
module TurnipFormatter
|
2
5
|
module Resource
|
3
6
|
module Step
|
4
|
-
class
|
7
|
+
class Hook
|
8
|
+
include ::TurnipFormatter::Resource::Step::FailureResult
|
9
|
+
include ::TurnipFormatter::Resource::Step::PendingResult
|
10
|
+
|
5
11
|
attr_reader :example
|
6
|
-
attr_reader :exceptions
|
7
12
|
|
8
13
|
#
|
9
14
|
# @param [RSpec::Core::Example] example
|
@@ -13,12 +18,15 @@ module TurnipFormatter
|
|
13
18
|
@exceptions = []
|
14
19
|
end
|
15
20
|
|
16
|
-
def set_exceptions(exceptions)
|
17
|
-
@exceptions = exceptions
|
18
|
-
end
|
19
|
-
|
20
21
|
def status
|
21
|
-
|
22
|
+
case
|
23
|
+
when failed?
|
24
|
+
:failed
|
25
|
+
when pending?
|
26
|
+
:pending
|
27
|
+
else
|
28
|
+
:passed
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
def text
|
@@ -34,13 +42,13 @@ module TurnipFormatter
|
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
37
|
-
class BeforeHook <
|
45
|
+
class BeforeHook < Hook
|
38
46
|
def keyword
|
39
47
|
'BeforeHook'
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
43
|
-
class AfterHook <
|
51
|
+
class AfterHook < Hook
|
44
52
|
def keyword
|
45
53
|
'AfterHook'
|
46
54
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TurnipFormatter
|
2
|
+
module Resource
|
3
|
+
module Step
|
4
|
+
module PendingResult
|
5
|
+
attr_reader :pending_message
|
6
|
+
attr_reader :pending_location
|
7
|
+
|
8
|
+
def pending?
|
9
|
+
!pending_message.nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
def set_pending(message, location)
|
13
|
+
@pending_message = message
|
14
|
+
@pending_location = location
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'turnip_formatter/resource/step/failure_result'
|
3
|
+
require 'turnip_formatter/resource/step/pending_result'
|
4
|
+
|
5
|
+
module TurnipFormatter
|
6
|
+
module Resource
|
7
|
+
module Step
|
8
|
+
class Step
|
9
|
+
include ::TurnipFormatter::Resource::Step::FailureResult
|
10
|
+
include ::TurnipFormatter::Resource::Step::PendingResult
|
11
|
+
|
12
|
+
extend Forwardable
|
13
|
+
def_delegators :@raw, :keyword, :text, :line, :argument
|
14
|
+
|
15
|
+
attr_reader :example
|
16
|
+
|
17
|
+
#
|
18
|
+
# @param [RSpec::Core::Example] example
|
19
|
+
# @param [Turnip::Node::Step] raw
|
20
|
+
#
|
21
|
+
def initialize(example, raw)
|
22
|
+
@example = example
|
23
|
+
@raw = raw
|
24
|
+
@executed = false
|
25
|
+
end
|
26
|
+
|
27
|
+
def mark_as_executed
|
28
|
+
@executed = true
|
29
|
+
end
|
30
|
+
|
31
|
+
def executed?
|
32
|
+
@executed
|
33
|
+
end
|
34
|
+
|
35
|
+
def status
|
36
|
+
case
|
37
|
+
when failed?
|
38
|
+
:failed
|
39
|
+
when pending?
|
40
|
+
:pending
|
41
|
+
when executed?
|
42
|
+
:passed
|
43
|
+
else
|
44
|
+
:unexecute
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/test/helper.rb
CHANGED
@@ -2,6 +2,8 @@ require 'test/unit'
|
|
2
2
|
require 'oga'
|
3
3
|
require 'tempfile'
|
4
4
|
require 'turnip_formatter/ext/turnip/rspec'
|
5
|
+
require 'turnip_formatter/resource/scenario/failure'
|
6
|
+
require 'turnip_formatter/resource/scenario/pending'
|
5
7
|
|
6
8
|
def html_parse(str)
|
7
9
|
Oga.parse_xml(str)
|
@@ -15,6 +17,29 @@ module TurnipFormatter
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
20
|
+
def dummy_failed_step
|
21
|
+
feature = feature_build(<<-EOS)
|
22
|
+
Feature: feature
|
23
|
+
Scenario: Failed
|
24
|
+
When [ERROR]
|
25
|
+
EOS
|
26
|
+
|
27
|
+
TurnipFormatter::Resource::Scenario::Failure.new(
|
28
|
+
run_feature(feature, '/path/to/test.feature').first
|
29
|
+
).steps[0]
|
30
|
+
end
|
31
|
+
|
32
|
+
def dummy_pending_step
|
33
|
+
feature = feature_build(<<-EOS)
|
34
|
+
Feature: feature
|
35
|
+
Scenario: Pending
|
36
|
+
When [PENDING]
|
37
|
+
EOS
|
38
|
+
TurnipFormatter::Resource::Scenario::Pending.new(
|
39
|
+
run_feature(feature, '/path/to/test.feature').first
|
40
|
+
).steps[0]
|
41
|
+
end
|
42
|
+
|
18
43
|
#
|
19
44
|
# @param text [String] feature text
|
20
45
|
# @return [Turnip::Node::Feature]
|
@@ -47,8 +72,7 @@ module TurnipFormatter
|
|
47
72
|
# Emulate Turnip::RSpec#run_feature
|
48
73
|
#
|
49
74
|
# @param feature [Turnip::Node::Feature]
|
50
|
-
# @param
|
51
|
-
# @param feature_file_path [String]
|
75
|
+
# @param filename [String]
|
52
76
|
#
|
53
77
|
# @return [Array<RSpec::Core::Example>] Array of example for scenarios.
|
54
78
|
#
|
@@ -7,7 +7,8 @@ module TurnipFormatter::Renderer::Html
|
|
7
7
|
|
8
8
|
sub_test_case 'step without argument' do
|
9
9
|
def setup
|
10
|
-
resource = TurnipFormatter::Resource::Step::
|
10
|
+
resource = TurnipFormatter::Resource::Step::Step.new(nil, sample_step)
|
11
|
+
resource.mark_as_executed
|
11
12
|
@renderer = Step.new(resource)
|
12
13
|
end
|
13
14
|
|
@@ -22,7 +23,8 @@ module TurnipFormatter::Renderer::Html
|
|
22
23
|
|
23
24
|
sub_test_case 'step with argument' do
|
24
25
|
def setup
|
25
|
-
resource = TurnipFormatter::Resource::Step::
|
26
|
+
resource = TurnipFormatter::Resource::Step::Step.new(nil, sample_step_with_docstring)
|
27
|
+
resource.mark_as_executed
|
26
28
|
@renderer = Step.new(resource)
|
27
29
|
end
|
28
30
|
|
@@ -36,7 +38,8 @@ module TurnipFormatter::Renderer::Html
|
|
36
38
|
|
37
39
|
sub_test_case 'step should be escaped html style' do
|
38
40
|
def setup
|
39
|
-
resource = TurnipFormatter::Resource::Step::
|
41
|
+
resource = TurnipFormatter::Resource::Step::Step.new(nil, sample_step_should_escaping)
|
42
|
+
resource.mark_as_executed
|
40
43
|
@renderer = Step.new(resource)
|
41
44
|
end
|
42
45
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'turnip_formatter/step_template/base'
|
3
|
+
|
4
|
+
module TurnipFormatter::StepTemplate
|
5
|
+
class TestBase < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@backup_templates = TurnipFormatter.step_templates
|
8
|
+
TurnipFormatter.step_templates.clear
|
9
|
+
|
10
|
+
Class.new(TurnipFormatter::StepTemplate::Base) do
|
11
|
+
on_passed :build_passed
|
12
|
+
on_failed :build_failed1
|
13
|
+
on_failed :build_failed2
|
14
|
+
on_pending :build_pending
|
15
|
+
|
16
|
+
def build_passed(_) ; 'build_passed' ; end
|
17
|
+
def build_failed1(_) ; 'build_failed' ; end
|
18
|
+
def build_failed2(_) ; 'hello_world' ; end
|
19
|
+
def build_pending(_) ; 'build_pending' ; end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
TurnipFormatter.step_templates.clear
|
25
|
+
@backup_templates.each do |t|
|
26
|
+
TurnipFormatter.step_templates << t
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_on_passed
|
31
|
+
text = TurnipFormatter.step_templates_for(:passed).map do |t, m|
|
32
|
+
t.send(m, nil)
|
33
|
+
end.join
|
34
|
+
|
35
|
+
assert_equal('build_passed', text)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_on_failed
|
39
|
+
text = TurnipFormatter.step_templates_for(:failed).map do |t, m|
|
40
|
+
t.send(m, nil)
|
41
|
+
end.join
|
42
|
+
|
43
|
+
assert_equal('build_failedhello_world', text)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_on_pending
|
47
|
+
text = TurnipFormatter.step_templates_for(:pending).map do |t, m|
|
48
|
+
t.send(m, nil)
|
49
|
+
end.join
|
50
|
+
|
51
|
+
assert_equal('build_pending', text)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'turnip_formatter/step_template/base'
|
3
|
+
|
4
|
+
module TurnipFormatter::StepTemplate
|
5
|
+
class TestException < Test::Unit::TestCase
|
6
|
+
include TurnipFormatter::TestHelper
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@backup_templates = TurnipFormatter.step_templates
|
10
|
+
TurnipFormatter.step_templates.clear
|
11
|
+
|
12
|
+
@template = TurnipFormatter::StepTemplate::Exception.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
TurnipFormatter.step_templates.clear
|
17
|
+
@backup_templates.each do |t|
|
18
|
+
TurnipFormatter.step_templates << t
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_build_failed
|
23
|
+
actual = @template.build_failed(dummy_failed_step)
|
24
|
+
assert_match(%r{<div class="step_exception">}, actual)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_build_pending
|
28
|
+
actual = @template.build_pending(dummy_pending_step)
|
29
|
+
assert_match(%r{<div class="step_exception">}, actual)
|
30
|
+
assert_match(%r{<pre>No such step}, actual)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'turnip_formatter/step_template/base'
|
3
|
+
|
4
|
+
module TurnipFormatter::StepTemplate
|
5
|
+
class TestSource < Test::Unit::TestCase
|
6
|
+
include TurnipFormatter::TestHelper
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@backup_templates = TurnipFormatter.step_templates
|
10
|
+
TurnipFormatter.step_templates.clear
|
11
|
+
|
12
|
+
@template = TurnipFormatter::StepTemplate::Exception.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
TurnipFormatter.step_templates.clear
|
17
|
+
@backup_templates.each do |t|
|
18
|
+
TurnipFormatter.step_templates << t
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_build_failed
|
23
|
+
actual = @template.build_failed(dummy_failed_step)
|
24
|
+
assert_match(%r{<div class="step_exception">}, actual)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/turnip_formatter.gemspec
CHANGED
@@ -15,11 +15,10 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^
|
18
|
+
spec.test_files = spec.files.grep(%r{^test/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'turnip', '~> 3.0.0
|
22
|
-
spec.add_dependency 'slim'
|
21
|
+
spec.add_dependency 'turnip', '~> 3.0.0'
|
23
22
|
spec.add_dependency 'rspec', [">=3.3", "<3.5"]
|
24
23
|
|
25
24
|
# For ruby >= 2.1
|
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
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wataru MIYAGUNI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: turnip
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.0.0
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: slim
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: 3.0.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,10 +178,8 @@ extensions: []
|
|
192
178
|
extra_rdoc_files: []
|
193
179
|
files:
|
194
180
|
- ".gitignore"
|
195
|
-
- ".rspec"
|
196
181
|
- ".travis.yml"
|
197
182
|
- Gemfile
|
198
|
-
- Guardfile
|
199
183
|
- LICENSE.txt
|
200
184
|
- README.md
|
201
185
|
- Rakefile
|
@@ -250,24 +234,15 @@ files:
|
|
250
234
|
- lib/turnip_formatter/resource/scenario/failure.rb
|
251
235
|
- lib/turnip_formatter/resource/scenario/pass.rb
|
252
236
|
- lib/turnip_formatter/resource/scenario/pending.rb
|
253
|
-
- lib/turnip_formatter/resource/step/
|
254
|
-
- lib/turnip_formatter/resource/step/failure.rb
|
237
|
+
- lib/turnip_formatter/resource/step/failure_result.rb
|
255
238
|
- lib/turnip_formatter/resource/step/hook.rb
|
256
|
-
- lib/turnip_formatter/resource/step/
|
257
|
-
- lib/turnip_formatter/resource/step/
|
258
|
-
- lib/turnip_formatter/resource/step/unexecute.rb
|
239
|
+
- lib/turnip_formatter/resource/step/pending_result.rb
|
240
|
+
- lib/turnip_formatter/resource/step/step.rb
|
259
241
|
- lib/turnip_formatter/step_template/base.rb
|
260
242
|
- lib/turnip_formatter/step_template/exception.html.erb
|
261
243
|
- lib/turnip_formatter/step_template/exception.rb
|
262
244
|
- lib/turnip_formatter/template.rb
|
263
245
|
- lib/turnip_formatter/version.rb
|
264
|
-
- spec/spec_helper.rb
|
265
|
-
- spec/support/example_helper.rb
|
266
|
-
- spec/support/passed.feature
|
267
|
-
- spec/support/step_helper.rb
|
268
|
-
- spec/turnip_formatter/step_template/base_spec.rb
|
269
|
-
- spec/turnip_formatter/step_template/exception_spec.rb
|
270
|
-
- spec/turnip_formatter/step_template/source_spec.rb
|
271
246
|
- test/helper.rb
|
272
247
|
- test/turnip_formatter/renderer/html/test_data_table.rb
|
273
248
|
- test/turnip_formatter/renderer/html/test_doc_string.rb
|
@@ -281,6 +256,9 @@ files:
|
|
281
256
|
- test/turnip_formatter/resource/scenario/test_failure.rb
|
282
257
|
- test/turnip_formatter/resource/scenario/test_pass.rb
|
283
258
|
- test/turnip_formatter/resource/scenario/test_pending.rb
|
259
|
+
- test/turnip_formatter/step_template/test_base.rb
|
260
|
+
- test/turnip_formatter/step_template/test_exception.rb
|
261
|
+
- test/turnip_formatter/step_template/test_source.rb
|
284
262
|
- turnip_formatter.gemspec
|
285
263
|
homepage: https://github.com/gongo/turnip_formatter
|
286
264
|
licenses:
|
@@ -297,9 +275,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
297
275
|
version: '0'
|
298
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
277
|
requirements:
|
300
|
-
- - "
|
278
|
+
- - ">="
|
301
279
|
- !ruby/object:Gem::Version
|
302
|
-
version:
|
280
|
+
version: '0'
|
303
281
|
requirements: []
|
304
282
|
rubyforge_project:
|
305
283
|
rubygems_version: 2.5.1
|
@@ -307,10 +285,19 @@ signing_key:
|
|
307
285
|
specification_version: 4
|
308
286
|
summary: RSpec custom formatter for Turnip
|
309
287
|
test_files:
|
310
|
-
-
|
311
|
-
-
|
312
|
-
-
|
313
|
-
-
|
314
|
-
-
|
315
|
-
-
|
316
|
-
-
|
288
|
+
- test/helper.rb
|
289
|
+
- test/turnip_formatter/renderer/html/test_data_table.rb
|
290
|
+
- test/turnip_formatter/renderer/html/test_doc_string.rb
|
291
|
+
- test/turnip_formatter/renderer/html/test_index.rb
|
292
|
+
- test/turnip_formatter/renderer/html/test_runtime_error.rb
|
293
|
+
- test/turnip_formatter/renderer/html/test_statistics_feature.rb
|
294
|
+
- test/turnip_formatter/renderer/html/test_statistics_speed.rb
|
295
|
+
- test/turnip_formatter/renderer/html/test_statistics_tag.rb
|
296
|
+
- test/turnip_formatter/renderer/html/test_step.rb
|
297
|
+
- test/turnip_formatter/renderer/test_html.rb
|
298
|
+
- test/turnip_formatter/resource/scenario/test_failure.rb
|
299
|
+
- test/turnip_formatter/resource/scenario/test_pass.rb
|
300
|
+
- test/turnip_formatter/resource/scenario/test_pending.rb
|
301
|
+
- test/turnip_formatter/step_template/test_base.rb
|
302
|
+
- test/turnip_formatter/step_template/test_exception.rb
|
303
|
+
- test/turnip_formatter/step_template/test_source.rb
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--colour
|
data/Guardfile
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
guard 'rspec' do
|
2
|
-
watch(%r{^spec/.+_spec\.rb$})
|
3
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
|
-
watch('spec/spec_helper.rb') { "spec" }
|
5
|
-
end
|
6
|
-
|
7
|
-
guard 'rspec', cli: '-r ./spec/examples/spec_helper' do
|
8
|
-
watch('lib/turnip_formatter/formatter.css') { "spec/examples" }
|
9
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Resource
|
5
|
-
module Step
|
6
|
-
class Base
|
7
|
-
extend Forwardable
|
8
|
-
def_delegators :@raw, :keyword, :text, :line, :argument
|
9
|
-
|
10
|
-
attr_reader :example
|
11
|
-
attr_accessor :status
|
12
|
-
|
13
|
-
#
|
14
|
-
# @param [RSpec::Core::Example] example
|
15
|
-
# @param [Turnip::Node::Step] raw
|
16
|
-
#
|
17
|
-
def initialize(example, raw)
|
18
|
-
@example = example
|
19
|
-
@raw = raw
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'turnip_formatter/resource/step/base'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Resource
|
5
|
-
module Step
|
6
|
-
class Failure < Base
|
7
|
-
attr_reader :exceptions
|
8
|
-
|
9
|
-
def initialize(example, raw)
|
10
|
-
super
|
11
|
-
@exceptions = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def status
|
15
|
-
:failed
|
16
|
-
end
|
17
|
-
|
18
|
-
#
|
19
|
-
# @param [Array<Exception>] exceptions
|
20
|
-
#
|
21
|
-
def set_exceptions(exceptions)
|
22
|
-
@exceptions = exceptions
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'turnip_formatter/resource/step/base'
|
2
|
-
|
3
|
-
module TurnipFormatter
|
4
|
-
module Resource
|
5
|
-
module Step
|
6
|
-
class Pending < Base
|
7
|
-
def status
|
8
|
-
:pending
|
9
|
-
end
|
10
|
-
|
11
|
-
def pending_message
|
12
|
-
example.execution_result.pending_message
|
13
|
-
end
|
14
|
-
|
15
|
-
def pending_location
|
16
|
-
example.location
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
if !defined?(JRUBY_VERSION)
|
2
|
-
require 'simplecov'
|
3
|
-
require 'coveralls'
|
4
|
-
|
5
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
6
|
-
SimpleCov.start do
|
7
|
-
add_filter 'spec/'
|
8
|
-
add_filter 'vendor/'
|
9
|
-
add_filter 'lib/turnip_formatter/ext'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'turnip_formatter'
|
14
|
-
Dir.glob(File.dirname(__FILE__) + '/support/**/*.rb') { |f| require(f) }
|
15
|
-
|
16
|
-
class NoopObject
|
17
|
-
def method_missing(name, *args, &block)
|
18
|
-
# nooooooop
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
RSpec.configure do |config|
|
23
|
-
config.include ExampleHelper
|
24
|
-
config.include StepHelper
|
25
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module ExampleHelper
|
2
|
-
def passed_example
|
3
|
-
base_example { expect(true).to be true }
|
4
|
-
end
|
5
|
-
|
6
|
-
def failed_example
|
7
|
-
base_example { expect(true).to be false }
|
8
|
-
end
|
9
|
-
|
10
|
-
def pending_example
|
11
|
-
example = if ::RSpec::Version::STRING >= '2.99.0'
|
12
|
-
base_example { skip('No such step(0): ') }
|
13
|
-
else
|
14
|
-
base_example { pending('No such step(0): ') }
|
15
|
-
end
|
16
|
-
|
17
|
-
# Turnip::Rspec::Execute#run_step
|
18
|
-
example.metadata[:line_number] = 10
|
19
|
-
example.metadata[:location] = "#{example.metadata[:file_path]}:10"
|
20
|
-
example
|
21
|
-
end
|
22
|
-
|
23
|
-
def create_step_node(keyword, text, line)
|
24
|
-
step_metadata = {
|
25
|
-
type: :Step,
|
26
|
-
location: { line: line, column: 1 },
|
27
|
-
keyword: keyword,
|
28
|
-
text: text,
|
29
|
-
argument: nil
|
30
|
-
}
|
31
|
-
|
32
|
-
Turnip::Node::Step.new(step_metadata)
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def base_example(&assertion)
|
38
|
-
group = ::RSpec::Core::ExampleGroup.describe('Feature').describe('Scenario')
|
39
|
-
example = group.example('example', example_metadata, &assertion)
|
40
|
-
example.metadata[:file_path] = '/path/to/hoge.feature'
|
41
|
-
|
42
|
-
instance_eval <<-EOS, example.metadata[:file_path], 10
|
43
|
-
group.run(NoopObject.new)
|
44
|
-
EOS
|
45
|
-
|
46
|
-
example
|
47
|
-
end
|
48
|
-
|
49
|
-
def example_metadata
|
50
|
-
{
|
51
|
-
turnip_formatter: {
|
52
|
-
steps: [create_step_node('Step', 'Step 1', 1)],
|
53
|
-
tags: []
|
54
|
-
}
|
55
|
-
}
|
56
|
-
end
|
57
|
-
end
|
data/spec/support/passed.feature
DELETED
data/spec/support/step_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'support/example_helper'
|
2
|
-
|
3
|
-
module StepHelper
|
4
|
-
include ExampleHelper
|
5
|
-
|
6
|
-
def passed_step
|
7
|
-
base_step(passed_example)
|
8
|
-
end
|
9
|
-
|
10
|
-
def failed_step
|
11
|
-
base_step(failed_example).tap { |s| s.status = :failed }
|
12
|
-
end
|
13
|
-
|
14
|
-
def pending_step
|
15
|
-
base_step(pending_example).tap { |s| s.status = :pending }
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def base_step(example)
|
21
|
-
TurnipFormatter::Resource::Step.new(example, step_description)
|
22
|
-
end
|
23
|
-
|
24
|
-
def step_description
|
25
|
-
create_step_node('Keyword', 'StepName', 1)
|
26
|
-
end
|
27
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/step_template/exception'
|
3
|
-
|
4
|
-
describe TurnipFormatter::StepTemplate::Base do
|
5
|
-
before do
|
6
|
-
@backup_templates = TurnipFormatter.step_templates
|
7
|
-
TurnipFormatter.step_templates.clear
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
@backup_templates.each do |t|
|
12
|
-
TurnipFormatter.step_templates << t
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context 'register step template' do
|
17
|
-
before do
|
18
|
-
Class.new(described_class) do
|
19
|
-
on_passed :build_passed
|
20
|
-
on_failed :build_failed1
|
21
|
-
on_failed :build_failed2
|
22
|
-
on_pending :build_pending
|
23
|
-
|
24
|
-
def build_passed(_)
|
25
|
-
'build_passed'
|
26
|
-
end
|
27
|
-
|
28
|
-
def build_failed1(_)
|
29
|
-
'build_failed'
|
30
|
-
end
|
31
|
-
|
32
|
-
def build_failed2(_)
|
33
|
-
'hello_world'
|
34
|
-
end
|
35
|
-
|
36
|
-
def build_pending(_)
|
37
|
-
'build_pending'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
after do
|
43
|
-
TurnipFormatter.step_templates.pop
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.on_passed' do
|
47
|
-
subject do
|
48
|
-
TurnipFormatter.step_templates_for(:passed).map do |template, method|
|
49
|
-
template.send(method, passed_example)
|
50
|
-
end.join
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns step document for passed' do
|
54
|
-
should eq 'build_passed'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '.on_failed' do
|
59
|
-
subject do
|
60
|
-
TurnipFormatter.step_templates_for(:failed).map do |template, method|
|
61
|
-
template.send(method, failed_example)
|
62
|
-
end.join
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'returns step document for failed' do
|
66
|
-
should eq 'build_failedhello_world'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '.on_pending' do
|
71
|
-
subject do
|
72
|
-
TurnipFormatter.step_templates_for(:pending).map do |template, method|
|
73
|
-
template.send(method, pending_example)
|
74
|
-
end.join
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'returns step document for failed' do
|
78
|
-
should eq 'build_pending'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/step_template/exception'
|
3
|
-
|
4
|
-
describe TurnipFormatter::StepTemplate::Exception do
|
5
|
-
after do
|
6
|
-
TurnipFormatter.step_templates.pop
|
7
|
-
end
|
8
|
-
|
9
|
-
let!(:template) do
|
10
|
-
described_class.new
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#build_failed' do
|
14
|
-
subject { template.build_failed(failed_example) }
|
15
|
-
|
16
|
-
it { should match %r{<div class="step_exception">} }
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#build_pending' do
|
20
|
-
subject { template.build_pending(pending_example) }
|
21
|
-
|
22
|
-
it { should match %r{<div class="step_exception">} }
|
23
|
-
it { should match %r{<pre>No such step} }
|
24
|
-
end
|
25
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'turnip_formatter/step_template/source'
|
3
|
-
|
4
|
-
describe TurnipFormatter::StepTemplate::Source do
|
5
|
-
let(:template) do
|
6
|
-
described_class.new
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '#build' do
|
10
|
-
subject { template.build(failed_example) }
|
11
|
-
|
12
|
-
it do
|
13
|
-
should match %r{<pre class="source">}
|
14
|
-
should match %r{<code class="ruby">}
|
15
|
-
should match %r{<span class="linenum">}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|