hiptest-publisher 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hiptest-publisher/handlebars_helper.rb +24 -2
  3. data/lib/hiptest-publisher/nodes.rb +8 -0
  4. data/lib/hiptest-publisher/options_parser.rb +2 -1
  5. data/lib/hiptest-publisher/render_context_maker.rb +2 -1
  6. data/lib/templates/javascript/_body.hbs +10 -0
  7. data/lib/templates/javascript/_item_as_function.hbs +3 -0
  8. data/lib/templates/javascript/_item_as_hash_key.hbs +3 -0
  9. data/lib/templates/javascript/_module_declaration.hbs +5 -0
  10. data/lib/templates/javascript/_scenario.hbs +4 -0
  11. data/lib/templates/javascript/actionword.hbs +1 -0
  12. data/lib/templates/javascript/actionwords.hbs +4 -0
  13. data/lib/templates/javascript/argument.hbs +1 -0
  14. data/lib/templates/javascript/assign.hbs +1 -0
  15. data/lib/templates/javascript/binaryexpression.hbs +1 -0
  16. data/lib/templates/javascript/call.hbs +1 -0
  17. data/lib/templates/javascript/dataset.hbs +3 -0
  18. data/lib/templates/javascript/dict.hbs +1 -0
  19. data/lib/templates/javascript/field.hbs +1 -0
  20. data/lib/templates/javascript/ifthen.hbs +7 -0
  21. data/lib/templates/javascript/index.hbs +1 -0
  22. data/lib/templates/javascript/jasmine/_before_each.hbs +3 -0
  23. data/lib/templates/javascript/jasmine/_scenario.hbs +8 -0
  24. data/lib/templates/javascript/jasmine/dataset.hbs +3 -0
  25. data/lib/templates/javascript/jasmine/output_config +7 -0
  26. data/lib/templates/javascript/jasmine/scenarios.hbs +8 -0
  27. data/lib/templates/javascript/jasmine/single_scenario.hbs +6 -0
  28. data/lib/templates/javascript/jasmine/single_test.hbs +6 -0
  29. data/lib/templates/javascript/jasmine/tests.hbs +8 -0
  30. data/lib/templates/javascript/list.hbs +1 -0
  31. data/lib/templates/javascript/nullliteral.hbs +1 -0
  32. data/lib/templates/javascript/output_config +7 -0
  33. data/lib/templates/javascript/parameter.hbs +1 -0
  34. data/lib/templates/javascript/parenthesis.hbs +1 -0
  35. data/lib/templates/javascript/project.hbs +2 -0
  36. data/lib/templates/javascript/property.hbs +1 -0
  37. data/lib/templates/javascript/scenario.hbs +1 -0
  38. data/lib/templates/javascript/scenarios.hbs +8 -0
  39. data/lib/templates/javascript/single_scenario.hbs +6 -0
  40. data/lib/templates/javascript/single_test.hbs +6 -0
  41. data/lib/templates/javascript/step.hbs +1 -0
  42. data/lib/templates/javascript/tag.hbs +1 -0
  43. data/lib/templates/javascript/template.hbs +1 -0
  44. data/lib/templates/javascript/test.hbs +1 -0
  45. data/lib/templates/javascript/tests.hbs +8 -0
  46. data/lib/templates/javascript/unaryexpression.hbs +1 -0
  47. data/lib/templates/javascript/while.hbs +5 -0
  48. metadata +44 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6e92271f76f876d63c2088cd01036d161d93696
4
- data.tar.gz: 461c0c357f267aad9d5b7506e68f27268bf9a2b0
3
+ metadata.gz: f37a960a49b7ddd172f81083a46b6c34292c0e68
4
+ data.tar.gz: ecb605e59814dd8272a0d6f5b327d9472c5462e4
5
5
  SHA512:
6
- metadata.gz: 235c3af05c37382a9b81ac2656fcb258d270174eb2c2a77a10aac15d57059415f7024dc8c3b6e16bfd63b6d5a00363ae3f65a2f44d85681d67178e5b49ba2d2a
7
- data.tar.gz: 98a68a2e0cd5ec6e87c23c5ed579ad79e9522c1b0d9848d90d1b8bc1f7d0022dd430a27b4b23bd9542accd9449d22a12c9596a439a343624e6cf9a20580151b4
6
+ metadata.gz: 5be537fba8c817478f7f8710855841c0ef19bd6af0e920d5086cf564f812f8c48ea0649e760efd1942f0e7867a62f738adfcd5628dbd803471ec3926f1bbf321
7
+ data.tar.gz: 7fee9c7166e142ba38db04fc06da758736491cea886a4f3c9732506b4b411d2b31a9caa6bb20b88f7276ba7e29b3aa1bbc99aadceb9c747909ed06eba93f7b30
@@ -42,9 +42,25 @@ module Hiptest
42
42
  "#{value.to_s}"
43
43
  end
44
44
 
45
- def hh_join(context, items, joiner, block)
45
+ def hh_join(context, items, joiner, block, else_block = nil)
46
46
  joiner = "\t" if joiner == '\t'
47
- "#{items.join(joiner)}"
47
+
48
+ if block.nil? || block.items.empty?
49
+ "#{items.join(joiner)}"
50
+ else
51
+ if items.empty? && else_block
52
+ return else_block.fn(context)
53
+ end
54
+
55
+ current_this = context.get('this')
56
+ result = items.map do |item|
57
+ context.add_item(:this, item)
58
+ block.fn(context)
59
+ end.join(joiner)
60
+
61
+ context.add_item(:this, current_this)
62
+ result
63
+ end
48
64
  end
49
65
 
50
66
  def hh_indent(context, block)
@@ -93,5 +109,11 @@ module Hiptest
93
109
  def hh_tab (context, block)
94
110
  "\t"
95
111
  end
112
+
113
+ def hh_debug(context, block)
114
+ require 'pry'
115
+ binding.pry
116
+ ""
117
+ end
96
118
  end
97
119
  end
@@ -230,6 +230,14 @@ module Hiptest
230
230
  :body => body
231
231
  }
232
232
  end
233
+
234
+ def declared_variables_names
235
+ p_names = children[:parameters].map {|p| p.children[:name]}
236
+ find_sub_nodes([Hiptest::Nodes::Variable]).map do |var|
237
+ v_name = var.children[:name]
238
+ p_names.include?(v_name) ? nil : v_name
239
+ end.uniq.compact
240
+ end
233
241
  end
234
242
 
235
243
  class Actionword < Item
@@ -64,7 +64,8 @@ class OptionsParser
64
64
  'Java' => ['JUnit', 'Test NG'],
65
65
  'Python' => ['Unittest'],
66
66
  'Robot Framework' => [''],
67
- 'Selenium IDE' => ['']
67
+ 'Selenium IDE' => [''],
68
+ 'Javascript' => ['qUnit', 'Jasmine']
68
69
  }
69
70
  end
70
71
 
@@ -5,7 +5,8 @@ module Hiptest
5
5
  :has_parameters? => !item.children[:parameters].empty?,
6
6
  :has_tags? => !item.children[:tags].empty?,
7
7
  :has_step? => !item.find_sub_nodes(Hiptest::Nodes::Step).empty?,
8
- :is_empty? => item.children[:body].empty?
8
+ :is_empty? => item.children[:body].empty?,
9
+ :declared_variables => item.declared_variables_names
9
10
  }
10
11
  end
11
12
 
@@ -0,0 +1,10 @@
1
+ {{#clear_empty_lines}}
2
+ {{#indent}}
3
+ {{#comment '//'}}{{{ rendered_children.description }}}{{/comment}}
4
+ {{#if has_tags?}}// Tags: {{{ join rendered_children.tags ' '}}}{{/if}}
5
+ {{#if declared_variables}}var {{#join declared_variables ', '}}{{{camelize_lower this}}}{{/join}};
6
+ {{/if}}{{#each rendered_children.body}}{{{this}}}
7
+ {{/each}}
8
+ {{#if has_step?}}throw 'Not implemented';{{/if}}
9
+ {{/indent}}
10
+ {{/clear_empty_lines}}
@@ -0,0 +1,3 @@
1
+ function {{ camelize_lower rendered_children.name }} ({{{ join rendered_children.parameters ', '}}}) {{#curly}}
2
+ {{> body}}
3
+ {{/curly}}
@@ -0,0 +1,3 @@
1
+ {{ camelize_lower rendered_children.name }}: function ({{{ join rendered_children.parameters ', '}}}) {{#curly}}
2
+ {{> body}}
3
+ {{/curly}}
@@ -0,0 +1,5 @@
1
+ module('{{{ remove_quotes project_name }}}', {{#curly}}
2
+ setup: function () {{#curly}}
3
+ this.actionwords = Object.create(Actionwords);
4
+ {{/curly}}
5
+ {{/curly}});
@@ -0,0 +1,4 @@
1
+ {{#if has_datasets?}}{{> item_as_function}}
2
+ {{{ rendered_children.datatable }}}{{else}}test('{{{ remove_quotes rendered_children.name }}}{{#if rendered_children.uid}} (uid:{{{rendered_children.uid}}}){{/if}}', function () {{#curly}}
3
+ {{> body}}
4
+ {{/curly}});{{/if}}
@@ -0,0 +1 @@
1
+ {{> item_as_hash_key}}
@@ -0,0 +1,4 @@
1
+ var Actionwords = {{#curly}}{{#indent}}{{#join rendered_children.actionwords ","}}
2
+ {{{this}}}{{/join}}
3
+ {{/indent}}
4
+ {{/curly}}
@@ -0,0 +1 @@
1
+ {{{ rendered_children.value }}}
@@ -0,0 +1 @@
1
+ {{{ rendered_children.to }}} = {{{ rendered_children.value }}};
@@ -0,0 +1 @@
1
+ {{{ rendered_children.left }}} {{{ rendered_children.operator }}} {{{ rendered_children.right }}}
@@ -0,0 +1 @@
1
+ this.{{#if context.call_prefix}}{{{ context.call_prefix }}}.{{/if}}{{{ camelize_lower rendered_children.actionword }}}({{{ join rendered_children.arguments ', '}}});
@@ -0,0 +1,3 @@
1
+ test('{{scenario_name}}: {{{remove_quotes rendered_children.name}}}{{#if rendered_children.uid}} (uid:{{{rendered_children.uid}}}){{/if}}', function () {{#curly}}
2
+ {{{ camelize_lower scenario_name }}}.apply(this, [{{{ join rendered_children.arguments ', ' }}}]);
3
+ {{/curly}});
@@ -0,0 +1 @@
1
+ {{#curly}}{{{ join rendered_children.items ', '}}}{{/curly}}
@@ -0,0 +1 @@
1
+ {{{ rendered_children.base }}}.{{{ rendered_children.name }}}
@@ -0,0 +1,7 @@
1
+ if ({{{ rendered_children.condition }}}) {{#curly}}
2
+ {{#indent}}{{#each rendered_children.then}}{{{this}}}{{/each}}
3
+ {{/indent}}
4
+ {{#if has_else?}}{{close_curly}} else {{open_curly}}
5
+ {{#indent}}{{#each rendered_children.else}}{{{this}}}{{/each}}
6
+ {{/indent}}
7
+ {{/if}}{{/curly}}
@@ -0,0 +1 @@
1
+ {{{ rendered_children.base }}}[{{{ rendered_children.expression }}}]
@@ -0,0 +1,3 @@
1
+ beforeEach(function () {{#curly}}
2
+ this.actionwords = Object.create(Actionwords);
3
+ {{/curly}});
@@ -0,0 +1,8 @@
1
+ {{#if has_datasets?}}describe('{{remove_quotes rendered_children.name}}', function () {{#curly}}{{#indent}}
2
+ {{> item_as_function}}
3
+ {{{ rendered_children.datatable }}}
4
+ {{/indent}}
5
+ {{/curly}});
6
+ {{else}}it('{{{ remove_quotes rendered_children.name }}}{{#if rendered_children.uid}} (uid:{{{rendered_children.uid}}}){{/if}}', function () {{#curly}}
7
+ {{> body}}
8
+ {{/curly}});{{/if}}
@@ -0,0 +1,3 @@
1
+ it('{{{remove_quotes rendered_children.name}}}{{#if rendered_children.uid}} (uid:{{{rendered_children.uid}}}){{/if}}', function () {{#curly}}
2
+ {{{ camelize_lower scenario_name }}}.apply(this, [{{{ join rendered_children.arguments ', ' }}}]);
3
+ {{/curly}});
@@ -0,0 +1,7 @@
1
+ [tests]
2
+ filename = 'project_test.js'
3
+ scenario_filename = '%s_test.js'
4
+ call_prefix = 'actionwords'
5
+
6
+ [actionwords]
7
+ filename = 'actionwords.js'
@@ -0,0 +1,8 @@
1
+ describe('{{{ remove_quotes project_name }}}', function () {{#curly}}{{#indent}}
2
+ {{> before_each}}
3
+
4
+ {{#each rendered_children.scenarios}}{{{this}}}
5
+
6
+ {{/each}}
7
+ {{/indent}}
8
+ {{/curly}});
@@ -0,0 +1,6 @@
1
+ describe('{{{ remove_quotes project_name }}}', function () {{#curly}}{{#indent}}
2
+ {{> before_each}}
3
+
4
+ {{> scenario}}
5
+ {{/indent}}
6
+ {{/curly}});
@@ -0,0 +1,6 @@
1
+ describe('{{{ remove_quotes project_name }}}', function () {{#curly}}{{#indent}}
2
+ {{> before_each}}
3
+
4
+ {{> scenario}}
5
+ {{/indent}}
6
+ {{/curly}});
@@ -0,0 +1,8 @@
1
+ describe('{{{ remove_quotes project_name }}}', function () {{#curly}}{{#indent}}
2
+ {{> before_each}}
3
+
4
+ {{#each rendered_children.tests}}{{{this}}}
5
+
6
+ {{/each}}
7
+ {{/indent}}
8
+ {{/curly}});
@@ -0,0 +1 @@
1
+ [{{{ join rendered_children.items ', '}}}]
@@ -0,0 +1 @@
1
+ null
@@ -0,0 +1,7 @@
1
+ [tests]
2
+ filename = 'project_test.js'
3
+ scenario_filename = '%s_test.js'
4
+ call_prefix = 'actionwords'
5
+
6
+ [actionwords]
7
+ filename = 'actionwords.js'
@@ -0,0 +1 @@
1
+ {{{ underscore rendered_children.name }}}
@@ -0,0 +1 @@
1
+ ({{{ rendered_children.content }}})
@@ -0,0 +1,2 @@
1
+ name: {{{ rendered_children.name }}}
2
+ description: {{{ rendered_children.description }}}
@@ -0,0 +1 @@
1
+ {{{ rendered_children.key }}}: {{{ rendered_children.value }}}
@@ -0,0 +1 @@
1
+ {{> scenario}}
@@ -0,0 +1,8 @@
1
+ (function () {{#curly}}{{#indent}}
2
+ {{> module_declaration}}
3
+
4
+ {{#each rendered_children.scenarios}}{{{this}}}
5
+
6
+ {{/each}}
7
+ {{/indent}}
8
+ {{/curly}})();
@@ -0,0 +1,6 @@
1
+ (function () {{#curly}}{{#indent}}
2
+ {{> module_declaration}}
3
+
4
+ {{> scenario}}
5
+ {{/indent}}
6
+ {{/curly}})();
@@ -0,0 +1,6 @@
1
+ (function () {{#curly}}{{#indent}}
2
+ {{> module_declaration}}
3
+
4
+ {{> scenario}}
5
+ {{/indent}}
6
+ {{/curly}})();
@@ -0,0 +1 @@
1
+ {{#comment '//'}}TODO: Implement {{{rendered_children.key}}}: {{{rendered_children.value}}}{{/comment}}
@@ -0,0 +1 @@
1
+ {{{ rendered_children.key }}}{{#if has_value?}}:{{{rendered_children.value}}}{{/if}}
@@ -0,0 +1 @@
1
+ {{#join treated_chunks ' + '}}{{#if this.is_variable?}}String({{{this.raw.children.name}}}){{else}}"{{{ escape_quotes this.raw.children.value }}}"{{/if}}{{/join}}
@@ -0,0 +1 @@
1
+ {{> scenario}}
@@ -0,0 +1,8 @@
1
+ (function () {{#curly}}{{#indent}}
2
+ {{> module_declaration}}
3
+
4
+ {{#each rendered_children.tests}}{{{this}}}
5
+
6
+ {{/each}}
7
+ {{/indent}}
8
+ {{/curly}})();
@@ -0,0 +1 @@
1
+ {{{ rendered_children.operator }}}{{{ rendered_children.expression }}}
@@ -0,0 +1,5 @@
1
+ while ({{{ rendered_children.condition }}}) {{#curly}}{{#indent}}
2
+ {{#each rendered_children.body }}{{{this}}}
3
+ {{/each}}
4
+ {{/indent}}
5
+ {{/curly}}
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.3.4
4
+ version: 0.3.5
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: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -302,6 +302,48 @@ files:
302
302
  - lib/templates/java/unaryexpression.hbs
303
303
  - lib/templates/java/variable.hbs
304
304
  - lib/templates/java/while.hbs
305
+ - lib/templates/javascript/_body.hbs
306
+ - lib/templates/javascript/_item_as_function.hbs
307
+ - lib/templates/javascript/_item_as_hash_key.hbs
308
+ - lib/templates/javascript/_module_declaration.hbs
309
+ - lib/templates/javascript/_scenario.hbs
310
+ - lib/templates/javascript/actionword.hbs
311
+ - lib/templates/javascript/actionwords.hbs
312
+ - lib/templates/javascript/argument.hbs
313
+ - lib/templates/javascript/assign.hbs
314
+ - lib/templates/javascript/binaryexpression.hbs
315
+ - lib/templates/javascript/call.hbs
316
+ - lib/templates/javascript/dataset.hbs
317
+ - lib/templates/javascript/dict.hbs
318
+ - lib/templates/javascript/field.hbs
319
+ - lib/templates/javascript/ifthen.hbs
320
+ - lib/templates/javascript/index.hbs
321
+ - lib/templates/javascript/jasmine/_before_each.hbs
322
+ - lib/templates/javascript/jasmine/_scenario.hbs
323
+ - lib/templates/javascript/jasmine/dataset.hbs
324
+ - lib/templates/javascript/jasmine/output_config
325
+ - lib/templates/javascript/jasmine/scenarios.hbs
326
+ - lib/templates/javascript/jasmine/single_scenario.hbs
327
+ - lib/templates/javascript/jasmine/single_test.hbs
328
+ - lib/templates/javascript/jasmine/tests.hbs
329
+ - lib/templates/javascript/list.hbs
330
+ - lib/templates/javascript/nullliteral.hbs
331
+ - lib/templates/javascript/output_config
332
+ - lib/templates/javascript/parameter.hbs
333
+ - lib/templates/javascript/parenthesis.hbs
334
+ - lib/templates/javascript/project.hbs
335
+ - lib/templates/javascript/property.hbs
336
+ - lib/templates/javascript/scenario.hbs
337
+ - lib/templates/javascript/scenarios.hbs
338
+ - lib/templates/javascript/single_scenario.hbs
339
+ - lib/templates/javascript/single_test.hbs
340
+ - lib/templates/javascript/step.hbs
341
+ - lib/templates/javascript/tag.hbs
342
+ - lib/templates/javascript/template.hbs
343
+ - lib/templates/javascript/test.hbs
344
+ - lib/templates/javascript/tests.hbs
345
+ - lib/templates/javascript/unaryexpression.hbs
346
+ - lib/templates/javascript/while.hbs
305
347
  - lib/templates/python/_body.hbs
306
348
  - lib/templates/python/_item_as_def.hbs
307
349
  - lib/templates/python/_parameters.hbs