flatware 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/flatware/checkpoint.rb +22 -0
- data/lib/flatware/cucumber/formatter.rb +17 -117
- data/lib/flatware/scenario_result.rb +7 -15
- data/lib/flatware/sink.rb +7 -4
- data/lib/flatware/step_result.rb +3 -3
- data/lib/flatware/summary.rb +4 -16
- data/lib/flatware/version.rb +3 -0
- metadata +3 -1
@@ -0,0 +1,22 @@
|
|
1
|
+
module Flatware
|
2
|
+
class Checkpoint
|
3
|
+
attr_reader :steps, :scenarios
|
4
|
+
def initialize(steps, scenarios)
|
5
|
+
@steps, @scenarios = serialize_steps(steps), serialize_scenarios(scenarios)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def serialize_steps(steps)
|
11
|
+
steps.map do |step|
|
12
|
+
StepResult.new step.status, step.exception
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def serialize_scenarios(scenarios)
|
17
|
+
scenarios.map do |scenario|
|
18
|
+
ScenarioResult.new scenario.status
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,149 +1,49 @@
|
|
1
1
|
require 'cucumber/formatter/console'
|
2
|
+
require 'flatware/checkpoint'
|
2
3
|
module Flatware
|
3
4
|
module Cucumber
|
4
5
|
class Formatter
|
5
6
|
def initialize(step_mother, *)
|
6
|
-
@
|
7
|
+
@collector = Collector.new step_mother
|
7
8
|
end
|
8
9
|
|
9
|
-
def
|
10
|
-
|
10
|
+
def after_features(*)
|
11
|
+
Sink.push collector.checkpoint
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
|
15
|
-
when ::Cucumber::Ast::ScenarioOutline
|
16
|
-
@outline_steps = feature_element
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def after_feature_element(feature_element)
|
21
|
-
@outline_steps = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
def after_feature(*)
|
25
|
-
background_steps.each do |step|
|
26
|
-
Sink.push step
|
27
|
-
end unless current_scenario
|
28
|
-
end
|
29
|
-
|
30
|
-
# keyword,
|
31
|
-
# step_match,
|
32
|
-
# multiline_arg,
|
33
|
-
# status,
|
34
|
-
# exception,
|
35
|
-
# source_indent,
|
36
|
-
# background,
|
37
|
-
# file_colon_line
|
38
|
-
def after_step_result(_, _, _, status, exception, _, background, _)
|
39
|
-
result = if status_only? background
|
40
|
-
background_steps << Result.background(status, exception)
|
41
|
-
Result.status status
|
42
|
-
else
|
43
|
-
Result.step status, exception, current_scenario
|
44
|
-
end
|
45
|
-
|
46
|
-
Sink.push result
|
47
|
-
end
|
48
|
-
|
49
|
-
def before_outline_table(outline_table)
|
50
|
-
@outline_table = outline_table
|
51
|
-
end
|
52
|
-
|
53
|
-
def after_outline_table(outline_table)
|
54
|
-
@outline_table = nil
|
55
|
-
end
|
56
|
-
|
57
|
-
def before_table_row(table_row)
|
58
|
-
if example_row? table_row
|
59
|
-
@step_collector = StepCollector.new(step_mother)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def after_table_row(table_row)
|
64
|
-
if example_row? table_row
|
65
|
-
step_collector.stop table_row
|
66
|
-
Sink.push Result.new step_collector.progress, step_collector.steps
|
67
|
-
end
|
14
|
+
def after_step_result(_, _, _, status, *)
|
15
|
+
send_progress(status)
|
68
16
|
end
|
69
17
|
|
70
18
|
def table_cell_value(_, status)
|
71
|
-
|
19
|
+
send_progress(status) if status
|
72
20
|
end
|
73
21
|
|
74
22
|
private
|
23
|
+
attr_reader :collector
|
75
24
|
|
76
|
-
|
77
|
-
|
78
|
-
def background_steps
|
79
|
-
@background_steps ||= []
|
25
|
+
def send_progress(status)
|
26
|
+
Sink.push Result.status status
|
80
27
|
end
|
81
28
|
|
82
|
-
|
83
|
-
scenario_outline? or (background and not current_scenario)
|
84
|
-
end
|
85
|
-
|
86
|
-
def scenario_outline?
|
87
|
-
!!@outline_steps
|
88
|
-
end
|
89
|
-
|
90
|
-
def example_row?(table_row)
|
91
|
-
table_row.respond_to? :failed? and outline_table? and not table_header_row? table_row
|
92
|
-
end
|
93
|
-
|
94
|
-
def example_cell?(status)
|
95
|
-
outline_table? and not table_header_cell? status
|
96
|
-
end
|
97
|
-
|
98
|
-
def table_header_cell?(status)
|
99
|
-
status == :skipped_param
|
100
|
-
end
|
101
|
-
|
102
|
-
def outline_table?
|
103
|
-
!!@outline_table
|
104
|
-
end
|
105
|
-
|
106
|
-
def table_header_row?(table_row)
|
107
|
-
table_row.failed?
|
108
|
-
rescue ::Cucumber::Ast::OutlineTable::ExampleRow::InvalidForHeaderRowError
|
109
|
-
true
|
110
|
-
else
|
111
|
-
false
|
112
|
-
end
|
113
|
-
|
114
|
-
class StepCollector
|
29
|
+
class Collector
|
115
30
|
attr_reader :step_mother
|
116
31
|
def initialize(step_mother)
|
117
32
|
@step_mother = step_mother
|
118
|
-
|
119
|
-
end
|
120
|
-
|
121
|
-
def stop(table_row)
|
122
|
-
@scenario_id = extract_scenario(table_row)
|
123
|
-
@example_row_steps = step_mother.steps - ran_steps
|
33
|
+
snapshot
|
124
34
|
end
|
125
35
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
StepResult.new(step.status, step.exception, scenario_id)
|
36
|
+
def checkpoint
|
37
|
+
Checkpoint.new(step_mother.steps - @ran_steps, step_mother.scenarios - @ran_scenarios).tap do
|
38
|
+
snapshot
|
130
39
|
end
|
131
40
|
end
|
132
41
|
|
133
|
-
def progress
|
134
|
-
''
|
135
|
-
end
|
136
|
-
|
137
42
|
private
|
138
43
|
|
139
|
-
|
140
|
-
|
141
|
-
def extract_scenario(table_row)
|
142
|
-
table_row.scenario_outline.file_colon_line(table_row.line)
|
143
|
-
end
|
144
|
-
|
145
|
-
def snapshot_steps
|
44
|
+
def snapshot
|
146
45
|
@ran_steps = step_mother.steps.dup
|
46
|
+
@ran_scenarios = step_mother.scenarios.dup
|
147
47
|
end
|
148
48
|
end
|
149
49
|
end
|
@@ -1,24 +1,16 @@
|
|
1
1
|
module Flatware
|
2
2
|
class ScenarioResult
|
3
|
-
attr_reader :
|
4
|
-
|
5
|
-
|
6
|
-
@id = id
|
7
|
-
@steps = steps
|
8
|
-
end
|
9
|
-
|
10
|
-
def status
|
11
|
-
first(:failed) || first(:undefined) || :passed
|
3
|
+
attr_reader :status
|
4
|
+
def initialize(status)
|
5
|
+
@status = status
|
12
6
|
end
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
def first(status)
|
17
|
-
statuses.detect {|s| s == status}
|
8
|
+
def passed?
|
9
|
+
status == :passed
|
18
10
|
end
|
19
11
|
|
20
|
-
def
|
21
|
-
|
12
|
+
def failed?
|
13
|
+
status == :failed
|
22
14
|
end
|
23
15
|
end
|
24
16
|
end
|
data/lib/flatware/sink.rb
CHANGED
@@ -41,7 +41,8 @@ module Flatware
|
|
41
41
|
case (result = Marshal.load message)
|
42
42
|
when Result
|
43
43
|
print result.progress
|
44
|
-
|
44
|
+
when Checkpoint
|
45
|
+
checkpoints << result
|
45
46
|
when Job
|
46
47
|
completed_jobs << result
|
47
48
|
log "COMPLETED SCENARIO"
|
@@ -67,7 +68,9 @@ module Flatware
|
|
67
68
|
end
|
68
69
|
|
69
70
|
def summarize
|
70
|
-
|
71
|
+
steps = checkpoints.map(&:steps).flatten
|
72
|
+
scenarios = checkpoints.map(&:scenarios).flatten
|
73
|
+
Summary.new(steps, scenarios, out).summarize
|
71
74
|
end
|
72
75
|
|
73
76
|
def summarize_remaining
|
@@ -91,8 +94,8 @@ module Flatware
|
|
91
94
|
die.send 'seppuku'
|
92
95
|
end
|
93
96
|
|
94
|
-
def
|
95
|
-
@
|
97
|
+
def checkpoints
|
98
|
+
@checkpoints ||= []
|
96
99
|
end
|
97
100
|
|
98
101
|
def completed_jobs
|
data/lib/flatware/step_result.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Flatware
|
2
2
|
class StepResult
|
3
|
-
attr_reader :status, :exception
|
3
|
+
attr_reader :status, :exception
|
4
4
|
|
5
|
-
def initialize(status, exception
|
6
|
-
@status, @exception
|
5
|
+
def initialize(status, exception)
|
6
|
+
@status, @exception = status, serialized(exception)
|
7
7
|
end
|
8
8
|
|
9
9
|
def passed?
|
data/lib/flatware/summary.rb
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
require 'cucumber/formatter/console'
|
2
|
+
require 'flatware/checkpoint'
|
2
3
|
module Flatware
|
3
4
|
class Summary
|
4
5
|
include ::Cucumber::Formatter::Console
|
5
|
-
attr_reader :io, :steps
|
6
|
+
attr_reader :io, :steps, :scenarios
|
6
7
|
|
7
|
-
def initialize(steps, io=StringIO.new)
|
8
|
+
def initialize(steps, scenarios=[], io=StringIO.new)
|
8
9
|
@io = io
|
9
10
|
@steps = steps
|
10
|
-
|
11
|
-
|
12
|
-
def scenarios
|
13
|
-
@scenarios ||= scenario_steps.group_by(&:scenario_id).map do |scenario, steps|
|
14
|
-
ScenarioResult.new(scenario, steps)
|
15
|
-
end
|
11
|
+
@scenarios = scenarios
|
16
12
|
end
|
17
13
|
|
18
14
|
def summarize
|
@@ -24,10 +20,6 @@ module Flatware
|
|
24
20
|
|
25
21
|
private
|
26
22
|
|
27
|
-
def scenario_steps
|
28
|
-
steps.select &:scenario_id
|
29
|
-
end
|
30
|
-
|
31
23
|
def print_steps(status)
|
32
24
|
print_elements steps.select(&with_status(status)), status, 'steps'
|
33
25
|
end
|
@@ -53,9 +45,5 @@ module Flatware
|
|
53
45
|
|
54
46
|
" (#{status_counts})"
|
55
47
|
end
|
56
|
-
|
57
|
-
def count(status)
|
58
|
-
completed_scenarios.select {|scenario| scenario.status == status}.count
|
59
|
-
end
|
60
48
|
end
|
61
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flatware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -123,6 +123,7 @@ extra_rdoc_files:
|
|
123
123
|
- README.rdoc
|
124
124
|
files:
|
125
125
|
- lib/flatware.rb
|
126
|
+
- lib/flatware/checkpoint.rb
|
126
127
|
- lib/flatware/cli.rb
|
127
128
|
- lib/flatware/cucumber.rb
|
128
129
|
- lib/flatware/cucumber/formatter.rb
|
@@ -134,6 +135,7 @@ files:
|
|
134
135
|
- lib/flatware/sink.rb
|
135
136
|
- lib/flatware/step_result.rb
|
136
137
|
- lib/flatware/summary.rb
|
138
|
+
- lib/flatware/version.rb
|
137
139
|
- lib/flatware/worker.rb
|
138
140
|
- LICENSE.txt
|
139
141
|
- README.rdoc
|