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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39afe8e077af4429d7ca2396b0b49191f18a8690
4
- data.tar.gz: 409aeaf3cc6bed1a076d68517a2533d7517ee983
3
+ metadata.gz: c4bf556535d34f99a46d459419144b12850f835a
4
+ data.tar.gz: 4d25694d6dd6bc45e91e58128fa5000f6ed1bd18
5
5
  SHA512:
6
- metadata.gz: f03ab8b780cee93cb22d5c36fccfaf63300986a7690f982193452ba703351521d921d17b051c653a556f9e6f1c4499f4488413a86059a84486541cfec806b444
7
- data.tar.gz: c04410ae58e6f8fc1fbb3a0cd2a4f52be7e7b596ebff9a7b6854761f33e7edb977af1a5a271a3115b23b98ef8d1e2460522f39d5b85c60a3504ec9b35a46a514
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::Call) do |call|
17
- call.children[:gherkin_text] ||= "#{text_annotation(call)} #{prettified(call)}"
18
- if actionword = get_actionword(call)
19
- actionword.children[:gherkin_annotation] ||= code_annotation(call)
20
- actionword.children[:gherkin_pattern] ||= pattern(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) || "Given"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiptest-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiptest R&D