hiptest-publisher 0.11.0 → 0.11.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: 9265f5d7fb656ed28ee0fa1c09a38538741bf11e
4
- data.tar.gz: 5888104486e35517396d17456b8cadc8d512803d
3
+ metadata.gz: be4a3b2d0bbf17ed7a2af2d6d5046741f7409132
4
+ data.tar.gz: 978b02362aaf8f9044aab395f52e36b6639eb9bb
5
5
  SHA512:
6
- metadata.gz: 7e818f3e3ebfc105196dba8c74b7df0cb10943eb1919b9cd8385cfb5978e4670198703204aa61433ddf1a17bd4a91e473485e25891683a9219a3ad773b90c9c2
7
- data.tar.gz: ead810b664042eb7a98fab859bc574c92ca0b27e211d9c8b83271461b365e2810bfeccfe84fed6db697d35c6c41ea81d5a50accc278474a8ab00703c91c0dde7
6
+ metadata.gz: aeb755943f4b5e5d3edd6a2449d782de32622dd7d4e233f6723cb5c90bd09a4f051bb1b3122ef16fa0bc969758d65fdf8e2c551f6dee4a6e08d51a504c35b834
7
+ data.tar.gz: 66d01375e139672cfc2976fc67273128e89690beb703e6e8f2692729ed2cdb454768134a1dadeea9c0d70e8bc2306f7a3445377b9a48414d1298699a06ae5976
@@ -3,6 +3,7 @@ template_dirs = robotframework, python, common
3
3
  indentation = "\t"
4
4
 
5
5
  [tests]
6
+ filename = 'test_project.txt'
6
7
  named_filename = 'test_%s.txt'
7
8
  filename_convention = 'underscore'
8
9
 
@@ -17,6 +17,7 @@ module Hiptest
17
17
  :normalize,
18
18
  :normalize_lower,
19
19
  :normalize_with_dashes,
20
+ :normalize_with_spaces,
20
21
  :underscore,
21
22
  :camelize,
22
23
  :camelize_lower,
@@ -46,7 +47,10 @@ module Hiptest
46
47
  end
47
48
 
48
49
  def hh_join(context, items, joiner, block, else_block = nil)
49
- joiner = "\t" if joiner == '\t'
50
+ joiner = joiner.to_s
51
+ joiner.gsub!(/\\t/, "\t")
52
+ joiner.gsub!(/\\n/, "\n")
53
+
50
54
 
51
55
  if block.nil? || block.items.empty?
52
56
  "#{items.join(joiner)}"
@@ -78,17 +82,21 @@ module Hiptest
78
82
  end
79
83
  end
80
84
 
81
- def hh_indent(context, block)
82
- indentation = @context[:indentation] || ' '
83
- indentation = "\t" if indentation == '\t'
84
-
85
+ def hh_prepend(context, str, block)
85
86
  block.fn(context).split("\n").map do |line|
86
- indented = "#{indentation}#{line}"
87
+ indented = "#{str}#{line}"
87
88
  indented = "" if indented.strip.empty?
88
89
  indented
89
90
  end.join("\n")
90
91
  end
91
92
 
93
+ def hh_indent(context, block)
94
+ indentation = @context[:indentation] || ' '
95
+ indentation = "\t" if indentation == '\t'
96
+
97
+ hh_prepend(context, indentation, block)
98
+ end
99
+
92
100
  def hh_clear_empty_lines(context, block)
93
101
  block.fn(context).split("\n").map do |line|
94
102
  line unless line.strip.empty?
@@ -28,15 +28,15 @@ module Hiptest
28
28
  :self_name => folder.children[:name],
29
29
  :has_tags? => !folder.children[:tags].empty?,
30
30
  :has_step? => has_step?(folder),
31
- :is_empty? => folder.children[:body].empty?
31
+ :is_empty? => folder.children[:body].empty?,
32
+ :datatables_present? => datatable_present?(folder),
32
33
  )
33
34
  end
34
35
 
35
36
  def walk_scenario(scenario)
36
- datatable = scenario.children[:datatable]
37
37
  walk_item(scenario).merge(walk_relative_item(scenario)).merge(
38
38
  :project_name => scenario.parent.parent.children[:name],
39
- :has_datasets? => datatable ? !datatable.children[:datasets].empty? : false
39
+ :has_datasets? => has_datasets?(scenario)
40
40
  )
41
41
  end
42
42
 
@@ -52,6 +52,7 @@ module Hiptest
52
52
  {
53
53
  :project_name => project.children[:name],
54
54
  :self_name => project.children[:name],
55
+ :datatables_present? => datatable_present?(scenarios)
55
56
  }
56
57
  end
57
58
 
@@ -71,7 +72,7 @@ module Hiptest
71
72
  project = tests.parent
72
73
  {
73
74
  :project_name => project.children[:name],
74
- :self_name => project.children[:name],
75
+ :self_name => project.children[:name]
75
76
  }
76
77
  end
77
78
 
@@ -123,5 +124,23 @@ module Hiptest
123
124
  end
124
125
  false
125
126
  end
127
+
128
+ def has_datasets?(scenario)
129
+ datatable = scenario.children[:datatable]
130
+ datatable ? !datatable.children[:datasets].empty? : false
131
+ end
132
+
133
+ def datatable_present?(container)
134
+ datatables_present = false
135
+
136
+ container.children[:scenarios].each do |scenario|
137
+ if has_datasets?(scenario)
138
+ datatables_present = true
139
+ break
140
+ end
141
+ end
142
+
143
+ return datatables_present
144
+ end
126
145
  end
127
146
  end
@@ -25,6 +25,22 @@ module Hiptest
25
25
  def call_node_walker(node)
26
26
  if node.is_a? Hiptest::Nodes::Node
27
27
  @rendered_children = {}
28
+
29
+ if node.is_a?(Hiptest::Nodes::Folder) || node.is_a?(Hiptest::Nodes::Scenarios)
30
+ # For Robot framework, we need direct access to every scenario
31
+ # datatables and body rendered ....
32
+
33
+ @rendered_children[:splitted_scenarios] = node.children[:scenarios].map {|sc|
34
+ {
35
+ name: @rendered[sc.children[:name]],
36
+ uid: @rendered[sc.children[:uid]],
37
+ datatable: @rendered[sc.children[:datatable]],
38
+ parameters: @rendered[sc.children[:parameters]],
39
+ body: @rendered[sc.children[:body]]
40
+ }
41
+ }
42
+ end
43
+
28
44
  node.children.each {|name, child| @rendered_children[name] = @rendered[child]}
29
45
  @rendered[node] = render_node(node, super(node))
30
46
  elsif node.is_a? Array
@@ -8,14 +8,20 @@ class String
8
8
  I18n.transliterate(self)
9
9
  end
10
10
 
11
- def normalize(keep_dashes=false)
11
+ def normalize(keep_dashes=false, keep_spaces=false)
12
12
  literated = self.literate
13
13
  literated.strip!
14
- literated.gsub!(/\s+/, '_')
15
- if keep_dashes
16
- literated.gsub!(/[^a-zA-Z0-9_\-]/, '')
14
+
15
+ if keep_spaces
16
+ literated.gsub!(/\s+/, ' ')
17
+ literated.gsub!(/[^a-zA-Z0-9_\- "']/, '')
17
18
  else
18
- literated.gsub!(/\W/, '')
19
+ literated.gsub!(/\s+/, '_')
20
+ if keep_dashes
21
+ literated.gsub!(/[^a-zA-Z0-9_\-]/, '')
22
+ else
23
+ literated.gsub!(/\W/, '')
24
+ end
19
25
  end
20
26
  literated
21
27
  end
@@ -30,6 +36,10 @@ class String
30
36
  self.normalize(true)
31
37
  end
32
38
 
39
+ def normalize_with_spaces
40
+ self.normalize(false, true)
41
+ end
42
+
33
43
  def underscore
34
44
  # based on:
35
45
  # http://stackoverflow.com/questions/1509915/converting-camel-case-to-underscore-case-in-ruby
@@ -1,5 +1,5 @@
1
1
  {{#if has_datasets?}}
2
- Test Template {{{ underscore rendered_children.name }}}
2
+ Test Template {{{ normalize_with_spaces rendered_children.name }}}
3
3
 
4
4
  *** Test Cases ***{{#each node.children.parameters}}{{{ tab }}}{{{ this.children.name}}}{{/each}}
5
5
  {{{ rendered_children.datatable }}}
@@ -8,4 +8,4 @@ Test Template {{{ underscore rendered_children.name }}}
8
8
  {{else}}
9
9
  *** Test Cases ***
10
10
  {{/if}}
11
- {{> keyword}}
11
+ {{{normalize_with_spaces rendered_children.name }}}{{#if rendered_children.uid}} (uid:{{normalize rendered_children.uid}}){{/if}}{{> keyword_body}}
@@ -1,2 +1 @@
1
- {{#if has_annotation? }}{{#comment '#'}}{{{ rendered_children.gherkin_text }}}{{/comment}}
2
- {{/if}}{{{ underscore rendered_children.actionword }}}{{#if has_arguments?}}{{tab}}{{{ join rendered_children.arguments '\t'}}}{{/if}}
1
+ {{{ underscore rendered_children.actionword }}}{{#if has_arguments?}}{{tab}}{{{ join rendered_children.arguments '\t'}}}{{/if}}
@@ -1 +1,30 @@
1
- PLEASE USE THE --split-scenarios OPTION WHEN PUBLISHING
1
+ *** Settings ***
2
+ Documentation
3
+ {{#comment '... '}}{{#clear_empty_lines}}
4
+ {{{ rendered_children.description}}}
5
+ {{#if has_tags?}}
6
+ Tags: {{{ join rendered_children.tags ' '}}}
7
+ {{/if}}{{/clear_empty_lines}}{{/comment}}
8
+ Resource keywords.txt
9
+ {{#unless is_empty?}}
10
+ Test Setup{{tab}}Run Keywords{{tab}}{{join rendered_children.body "\n... AND \t"}}
11
+ {{/unless}}
12
+ *** Test Cases ***{{#if datatables_present?}}
13
+ {{#each rendered_children.splitted_scenarios}}
14
+ {{#if this.datatable}}{{normalize_with_spaces this.name}}{{#indent}}
15
+ [Template]{{tab}}{{normalize_with_spaces this.name}} keyword
16
+ {{this.datatable}}{{/indent}}
17
+ {{else}}{{normalize_with_spaces this.name}}{{#if this.uid}}(uid:{{normalize this.uid}}){{/if}}{{#indent}}
18
+ {{join this.body '\n'}}{{/indent}}
19
+ {{/if}}{{/each}}
20
+ *** Keywords ***
21
+
22
+ {{#each rendered_children.splitted_scenarios}}{{#if this.datatable}}{{normalize_with_spaces this.name}} keyword{{#indent}}
23
+ [Arguments]{{tab}}${{#curly}}__test_name{{/curly}}{{tab}}{{join this.parameters '\t'}}
24
+ {{join this.body '\n'}}{{/indent}}
25
+
26
+ {{/if}}{{/each}}{{else}}
27
+ {{#each rendered_children.splitted_scenarios}}
28
+ {{normalize_with_spaces this.name}}{{#if this.uid}}(uid:{{normalize this.uid}}){{/if}}{{#indent}}
29
+ {{join this.body '\n'}}{{/indent}}
30
+ {{/each}}{{/if}}
@@ -1 +1,22 @@
1
- PLEASE USE THE --split-scenarios OPTION WHEN PUBLISHING
1
+ *** Settings ***
2
+ Resource keywords.txt
3
+
4
+ *** Test Cases ***{{#if datatables_present?}}
5
+ {{#each rendered_children.splitted_scenarios}}
6
+ {{#if this.datatable}}{{this.name}}{{#indent}}
7
+ [Template]{{tab}}{{this.name}} keyword
8
+ {{this.datatable}}{{/indent}}
9
+ {{else}}{{normalize_with_spaces this.name}}{{#if rendered_children.uid}} (uid:{{normalize rendered_children.uid}}){{/if}}{{#indent}}
10
+ {{join this.body '\n'}}{{/indent}}
11
+ {{/if}}{{/each}}
12
+ *** Keywords ***
13
+
14
+ {{#each rendered_children.splitted_scenarios}}{{#if this.datatable}}{{normalize_with_spaces this.name}} keyword{{#indent}}
15
+ [Arguments]{{tab}}${{#curly}}__test_name{{/curly}}{{tab}}{{join this.parameters '\t'}}
16
+ {{join this.body '\n'}}{{/indent}}
17
+
18
+ {{/if}}{{/each}}{{else}}
19
+ {{#each rendered_children.splitted_scenarios}}
20
+ {{normalize_with_spaces this.name}}{{#if rendered_children.uid}} (uid:{{normalize rendered_children.uid}}){{/if}}{{#indent}}
21
+ {{join this.body '\n'}}{{/indent}}
22
+ {{/each}}{{/if}}
@@ -0,0 +1 @@
1
+ {{{normalize_with_spaces rendered_children.name }}}{{#if rendered_children.uid}}_uid{{{ normalize rendered_children.uid}}}{{/if}}{{> keyword_body}}
@@ -1 +1,7 @@
1
- PLEASE USE THE --split-scenarios OPTION WHEN PUBLISHING
1
+ *** Settings ***
2
+ Resource keywords.txt
3
+
4
+ *** Test Cases ***
5
+ {{#each rendered_children.tests}}
6
+ {{this}}
7
+ {{/each}}
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: 0.11.0
4
+ version: 0.11.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: 2016-03-22 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -516,6 +516,7 @@ files:
516
516
  - lib/templates/robotframework/single_test.hbs
517
517
  - lib/templates/robotframework/stringliteral.hbs
518
518
  - lib/templates/robotframework/template.hbs
519
+ - lib/templates/robotframework/test.hbs
519
520
  - lib/templates/robotframework/tests.hbs
520
521
  - lib/templates/robotframework/variable.hbs
521
522
  - lib/templates/robotframework/while.hbs