hiptest-publisher 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiptest-publisher/gherkin_adder.rb +40 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4bf556535d34f99a46d459419144b12850f835a
|
4
|
+
data.tar.gz: 4d25694d6dd6bc45e91e58128fa5000f6ed1bd18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74ce1abdf0334e8528e08dcc6201b8bff3a158606a79e69fc67a98a068794080008d2b4fa791abc02db20b1749abf1998a44316a54259c665e09854c93c69e78
|
7
|
+
data.tar.gz: 2482949cd5d0d0682c9bcc86cd652128e7644331769612fc85e6ac74f92d24acf3e8fed883919e2d80d1a24ffc30ddace5dacaab0c886dc75b17d2861bae9d02
|
@@ -10,16 +10,24 @@ module Hiptest
|
|
10
10
|
def initialize(project)
|
11
11
|
@project = project
|
12
12
|
@indexer = ActionwordIndexer.new(project)
|
13
|
+
@annotations_counter = AnnotationsCounter.new
|
13
14
|
end
|
14
15
|
|
15
16
|
def update_calls
|
16
|
-
@project.each_sub_nodes(Hiptest::Nodes::
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
actionword
|
17
|
+
@project.each_sub_nodes(Hiptest::Nodes::Scenario, Hiptest::Nodes::Actionword, Hiptest::Nodes::Test) do |item|
|
18
|
+
@last_annotation = nil
|
19
|
+
item.each_sub_nodes(Hiptest::Nodes::Call) do |call|
|
20
|
+
call.children[:gherkin_text] ||= "#{text_annotation(call)} #{prettified(call)}"
|
21
|
+
if actionword = get_actionword(call)
|
22
|
+
@annotations_counter.increment(actionword, code_annotation(call))
|
23
|
+
actionword.children[:gherkin_pattern] ||= pattern(actionword)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
27
|
+
|
28
|
+
@annotations_counter.actionwords.each do |actionword|
|
29
|
+
actionword.children[:gherkin_annotation] = @annotations_counter.most_used_annotation(actionword) || "Given"
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
def annotation(call)
|
@@ -31,7 +39,13 @@ module Hiptest
|
|
31
39
|
end
|
32
40
|
|
33
41
|
def code_annotation(call)
|
34
|
-
annotation(call)
|
42
|
+
call_annotation = annotation(call)
|
43
|
+
if call_annotation
|
44
|
+
if call_annotation == "And"
|
45
|
+
call_annotation = @last_annotation || "Given"
|
46
|
+
end
|
47
|
+
@last_annotation = call_annotation
|
48
|
+
end
|
35
49
|
end
|
36
50
|
|
37
51
|
def prettified(call)
|
@@ -126,4 +140,24 @@ module Hiptest
|
|
126
140
|
end
|
127
141
|
end
|
128
142
|
end
|
143
|
+
|
144
|
+
class AnnotationsCounter
|
145
|
+
def initialize
|
146
|
+
@counts_by_actionword = Hash.new {|counts, actionword| counts[actionword] = Hash.new(0) }
|
147
|
+
end
|
148
|
+
|
149
|
+
def actionwords
|
150
|
+
@counts_by_actionword.keys
|
151
|
+
end
|
152
|
+
|
153
|
+
def increment(actionword, annotation)
|
154
|
+
counts = @counts_by_actionword[actionword]
|
155
|
+
counts[annotation] += 1 if annotation
|
156
|
+
end
|
157
|
+
|
158
|
+
def most_used_annotation(actionword)
|
159
|
+
max = @counts_by_actionword[actionword].values.max
|
160
|
+
@counts_by_actionword[actionword].key(max)
|
161
|
+
end
|
162
|
+
end
|
129
163
|
end
|