hiptest-publisher 1.18.0 → 1.18.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: baa4e4f8cd0e3988cc9ab2a42ea0574252662eadc92241365d9e3c4727c6c7de
4
- data.tar.gz: aa84ae8c99f14975ba9e1c5edaf80d88630ffe23bb0be29003cd432d9f25b175
3
+ metadata.gz: 72feb2ab6699c43b1e7db2704110ceb6a38ac0f5baaa14e0a21127988f7f66b1
4
+ data.tar.gz: a1885c484be7b91155c38c6ecc1e62010cc1060b3bc91922a1adcacc0af657eb
5
5
  SHA512:
6
- metadata.gz: 1e7a9d3e93ac0516e6a9fb89e4871452926082bedc81bdde2209060df2587f739159d9412ce4dfd6c6eb986c02640caf8136ae08d4fb7d0985d042a72525d3dc
7
- data.tar.gz: bc4191ba3cabe8cd7a7d996151dd5851661544f6ad78d0cb425b4be1f720419272258164d9d828c5ba42eacd9956095f71040b216e3d2bb2767a449d04d72b88
6
+ metadata.gz: 68e786fca0b041eb333b3be646d323917b9ffb0065517817143e0589c5feb767437b96706ff26047d706b2b39840f0d5f303c8f784c034dec8104d190394e92b
7
+ data.tar.gz: 6498a773930f218a251b3549819d70273c919fe919643e589733978003705503f1327b306a09ea72d064bce0602cfa5672c88e48d8b8da5bd9ace003a92d8ee1
@@ -74,7 +74,8 @@ module Hiptest
74
74
  call.chunks = []
75
75
  call.extra_inlined_arguments = []
76
76
 
77
- call_chunks = call.is_a?(Hiptest::Nodes::Call) ? call.children[:actionword].split("\"", -1) : call.children[:actionword_name].split("\"", -1)
77
+ actionword_name = call.is_a?(Hiptest::Nodes::Call) ? call.children[:actionword] : call.children[:actionword_name]
78
+ call_chunks = actionword_name.split("\"", -1)
78
79
 
79
80
  call_chunks.each_slice(2) do |text, inline_parameter_name|
80
81
  call.chunks << {
@@ -16,7 +16,10 @@ module Hiptest
16
16
  def update_uid_calls
17
17
  @project.each_sub_nodes(Hiptest::Nodes::UIDCall) do |uid_call|
18
18
  index = @indexer.get_index(uid_call.children[:uid])
19
- next if index.nil?
19
+ if index.nil?
20
+ uid_call.children[:actionword_name] = "Unknown actionword with UID: #{uid_call.children[:uid]}"
21
+ next
22
+ end
20
23
 
21
24
  uid_call.children[:actionword_name] = index[:actionword].children[:name]
22
25
  uid_call.children[:library_name] = index[:library].children[:name] unless index[:library].nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiptest-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.18.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiptest R&D
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-02 00:00:00.000000000 Z
11
+ date: 2019-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -255,7 +255,6 @@ files:
255
255
  - lib/hiptest-publisher/formatters/console_formatter.rb
256
256
  - lib/hiptest-publisher/formatters/diff_displayer.rb
257
257
  - lib/hiptest-publisher/formatters/reporter.rb
258
- - lib/hiptest-publisher/gherkin_adder.rb
259
258
  - lib/hiptest-publisher/handlebars_helper.rb
260
259
  - lib/hiptest-publisher/indexers/actionword_indexer.rb
261
260
  - lib/hiptest-publisher/indexers/actionword_uid_indexer.rb
@@ -1,238 +0,0 @@
1
- require 'hiptest-publisher/actionword_indexer'
2
- require 'hiptest-publisher/nodes'
3
-
4
- module Hiptest
5
- class GherkinAdder
6
- def self.add(project)
7
- GherkinAdder.new(project).update_calls
8
- end
9
-
10
- def initialize(project)
11
- @project = project
12
- @indexer = ActionwordIndexer.new(project)
13
- @annotations_counter = AnnotationsCounter.new
14
-
15
- @special_params = ['__free_text', '__datatable']
16
- end
17
-
18
- def update_calls
19
- @project.each_sub_nodes(Hiptest::Nodes::Scenario, Hiptest::Nodes::Actionword, Hiptest::Nodes::Test, Hiptest::Nodes::Folder) do |item|
20
- @last_annotation = nil
21
- item.each_sub_nodes(Hiptest::Nodes::Call) do |call|
22
- set_call_chunks(call)
23
- call.children[:gherkin_text] ||= "#{text_annotation(call)} #{prettified(call)}"
24
-
25
- if actionword = get_actionword(call)
26
- @annotations_counter.increment(actionword, code_annotation(call))
27
- set_actionwords_chunks(actionword)
28
-
29
- actionword.children[:gherkin_pattern] ||= pattern(actionword)
30
- actionword.children[:parameters_ordered_by_pattern] ||= order_parameters_by_pattern(actionword)
31
- end
32
- end
33
- end
34
-
35
- @annotations_counter.actionwords.each do |actionword|
36
- actionword.children[:gherkin_annotation] = @annotations_counter.most_used_annotation(actionword) || "Given"
37
- actionword.children[:gherkin_used_annotations] = @annotations_counter.all_used_annotations(actionword).any? ? @annotations_counter.all_used_annotations(actionword) :['Given']
38
- end
39
- end
40
-
41
- def annotation(call)
42
- call.children[:annotation].capitalize if call.children[:annotation]
43
- end
44
-
45
- def text_annotation(call)
46
- annotation(call) || "*"
47
- end
48
-
49
- def code_annotation(call)
50
- call_annotation = annotation(call)
51
- if call_annotation
52
- if ["And", "But"].include?(call_annotation)
53
- call_annotation = @last_annotation || "Given"
54
- end
55
- @last_annotation = call_annotation
56
- end
57
- end
58
-
59
- def prettified(call)
60
- base = call.chunks.map {|chunk| chunk[:value]}.join("\"").strip
61
- call.extra_inlined_arguments.each do |chunk|
62
- base += " \"#{chunk[:value]}\""
63
- end
64
-
65
- base
66
- end
67
-
68
- def set_call_chunks(call)
69
- all_arguments = all_valued_arguments_for(call)
70
- inline_parameter_names = []
71
- extra_inlined_arguments = []
72
-
73
- call.chunks = []
74
- call.extra_inlined_arguments = []
75
-
76
- call_chunks = call.children[:actionword].split("\"", -1)
77
- call_chunks.each_slice(2) do |text, inline_parameter_name|
78
- call.chunks << {
79
- value: text,
80
- is_argument: false
81
- }
82
-
83
- if all_arguments.has_key?(inline_parameter_name)
84
- inline_parameter_names << inline_parameter_name.clone
85
- value = all_arguments[inline_parameter_name]
86
- inline_parameter_name.replace(value)
87
-
88
- call.chunks << {
89
- value: inline_parameter_name,
90
- is_argument: true
91
- }
92
- else
93
- call.chunks << {
94
- value: inline_parameter_name,
95
- is_argument: false
96
- } unless inline_parameter_name.nil?
97
- end
98
- end
99
-
100
- missing_parameter_names = all_arguments.keys - inline_parameter_names - @special_params
101
- call.extra_inlined_arguments = missing_parameter_names.map do |missing_parameter_name|
102
- {
103
- value: all_arguments[missing_parameter_name],
104
- is_argument: true
105
- }
106
- end
107
- end
108
-
109
- def pattern(actionword)
110
- patterned = actionword.chunks.map {|chunk| chunk[:value]}.join("\"")
111
- actionword.extra_inlined_parameters.each do |param|
112
- patterned += " \"#{param[:value]}\""
113
- end
114
-
115
- "^#{patterned.strip}$"
116
- end
117
-
118
- def set_actionwords_chunks(actionword)
119
- name = actionword.children[:name]
120
- actionword_parameters = evaluated_map(actionword.children[:parameters])
121
- name_chunks = name.split("\"", -1)
122
- inline_parameter_names = []
123
-
124
- actionword.chunks = []
125
- actionword.extra_inlined_parameters = []
126
-
127
- name_chunks.each_slice(2) do |text, inline_parameter_name|
128
- actionword.chunks << {
129
- value: text.gsub(/[.|()\\.+*?\[\]{}^$]/) { |c| "\\#{c}" },
130
- is_parameter: false
131
- }
132
-
133
- inline_parameter_names << inline_parameter_name if inline_parameter_name
134
- if actionword_parameters.has_key?(inline_parameter_name)
135
- actionword.chunks << {
136
- value: "(.*)",
137
- name: inline_parameter_name,
138
- is_parameter: true
139
- }
140
- else
141
- actionword.chunks << {
142
- value: inline_parameter_name,
143
- is_parameter: false
144
- } if inline_parameter_name
145
- end
146
- end
147
- missing_parameter_names = actionword_parameters.keys - inline_parameter_names - @special_params
148
-
149
- missing_parameter_names.each do |missing_parameter_name|
150
- actionword.extra_inlined_parameters << {
151
- value: "(.*)",
152
- name: missing_parameter_name,
153
- is_parameter: true
154
- }
155
- end
156
- end
157
-
158
- def order_parameters_by_pattern(actionword)
159
- inline_parameter_names = actionword.children[:name].scan(/\"(.*?)\"/).flatten
160
- actionword_parameters = {}
161
- actionword.children[:parameters].map {|p| actionword_parameters[p.children[:name]] = p}
162
-
163
- missing_parameter_names = actionword_parameters.keys - inline_parameter_names - @special_params
164
- [inline_parameter_names, missing_parameter_names, @special_params].flatten.map do |name|
165
- actionword_parameters[name]
166
- end.compact
167
- end
168
-
169
- def all_valued_arguments_for(call)
170
- evaluated_call_arguments = evaluated_map(call.children[:arguments])
171
- evaluated_actionword_parameters = evaluated_map(get_actionword_parameters(call))
172
- names = evaluated_actionword_parameters.keys
173
-
174
- hash_array = names.map { |name|
175
- value = evaluated_call_arguments[name] || evaluated_actionword_parameters[name] || ""
176
- [name, value]
177
- }
178
- Hash[hash_array]
179
- end
180
-
181
- def get_actionword_parameters(call)
182
- actionword = get_actionword(call)
183
- actionword && actionword.children[:parameters] || []
184
- end
185
-
186
- def get_actionword(call)
187
- actionword = @indexer.get_index(call.children[:actionword])
188
- actionword && actionword[:actionword] || nil
189
- end
190
-
191
- def evaluated_map(named_values)
192
- hash_array = named_values.map do |named_value|
193
- name = named_value.children[:name]
194
- value = evaluate(named_value.children[:value] || named_value.children[:default])
195
- [name, value]
196
- end
197
- Hash[hash_array]
198
- end
199
-
200
- def evaluate(value)
201
- if value.nil?
202
- nil
203
- elsif Hiptest::Nodes::Variable === value
204
- "<#{value.children[:name]}>"
205
- elsif value.children[:chunks]
206
- value.children[:chunks].map {|chunk| evaluate(chunk) }.join('')
207
- elsif value.children[:value]
208
- value.children[:value]
209
- else
210
- nil
211
- end
212
- end
213
- end
214
-
215
- class AnnotationsCounter
216
- def initialize
217
- @counts_by_actionword = Hash.new {|counts, actionword| counts[actionword] = Hash.new(0) }
218
- end
219
-
220
- def actionwords
221
- @counts_by_actionword.keys
222
- end
223
-
224
- def increment(actionword, annotation)
225
- counts = @counts_by_actionword[actionword]
226
- counts[annotation] += 1 if annotation
227
- end
228
-
229
- def most_used_annotation(actionword)
230
- max = @counts_by_actionword[actionword].values.max
231
- @counts_by_actionword[actionword].key(max)
232
- end
233
-
234
- def all_used_annotations(actionword)
235
- @counts_by_actionword[actionword].keys
236
- end
237
- end
238
- end