hammer_cli 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/doc/installation.md +1 -1
  3. data/doc/release_notes.md +6 -0
  4. data/lib/hammer_cli/output/formatters.rb +7 -1
  5. data/lib/hammer_cli/testing/command_assertions.rb +119 -0
  6. data/lib/hammer_cli/testing/data_helpers.rb +19 -0
  7. data/lib/hammer_cli/testing/output_matchers.rb +105 -0
  8. data/lib/hammer_cli/version.rb +1 -1
  9. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  10. data/locale/de/hammer-cli.edit.po +16 -16
  11. data/locale/de/hammer-cli.po +1 -1
  12. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  13. data/locale/en/hammer-cli.po +1 -1
  14. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  15. data/locale/en_GB/hammer-cli.edit.po +25 -25
  16. data/locale/en_GB/hammer-cli.po +1 -1
  17. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  18. data/locale/es/hammer-cli.po +1 -1
  19. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  20. data/locale/fr/hammer-cli.edit.po +26 -26
  21. data/locale/fr/hammer-cli.po +1 -1
  22. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  23. data/locale/it/hammer-cli.edit.po +3 -3
  24. data/locale/it/hammer-cli.po +1 -1
  25. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  26. data/locale/ja/hammer-cli.edit.po +3 -3
  27. data/locale/ja/hammer-cli.po +1 -1
  28. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  29. data/locale/ko/hammer-cli.edit.po +3 -3
  30. data/locale/ko/hammer-cli.po +1 -1
  31. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  32. data/locale/pt_BR/hammer-cli.po +1 -1
  33. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  34. data/locale/ru/hammer-cli.edit.po +3 -3
  35. data/locale/ru/hammer-cli.po +1 -1
  36. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  37. data/locale/zh_CN/hammer-cli.edit.po +3 -3
  38. data/locale/zh_CN/hammer-cli.po +1 -1
  39. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  40. data/locale/zh_TW/hammer-cli.edit.po +3 -3
  41. data/locale/zh_TW/hammer-cli.po +1 -1
  42. data/test/functional/defaults_test.rb +85 -55
  43. data/test/functional/test_helper.rb +9 -0
  44. data/test/reports/TEST-Fields-ContainerField-display-.xml +1 -1
  45. data/test/reports/TEST-Fields-ContainerField-display-blank-is-allowed.xml +5 -5
  46. data/test/reports/TEST-Fields-ContainerField-display-blank-is-not-allowed.xml +5 -5
  47. data/test/reports/TEST-Fields-ContainerField.xml +1 -1
  48. data/test/reports/TEST-Fields-Field-display-.xml +1 -1
  49. data/test/reports/TEST-Fields-Field-display-blank-is-allowed.xml +3 -3
  50. data/test/reports/TEST-Fields-Field-display-blank-is-not-allowed.xml +3 -3
  51. data/test/reports/TEST-Fields-Field-hide-blank-.xml +3 -3
  52. data/test/reports/TEST-Fields-Field-parameters.xml +2 -2
  53. data/test/reports/TEST-Fields-Field.xml +4 -4
  54. data/test/reports/TEST-HammerCLI-AbstractCommand-build-options.xml +5 -5
  55. data/test/reports/TEST-HammerCLI-AbstractCommand-exception-handler.xml +4 -4
  56. data/test/reports/TEST-HammerCLI-AbstractCommand-logging.xml +8 -10
  57. data/test/reports/TEST-HammerCLI-AbstractCommand-option-builder.xml +3 -3
  58. data/test/reports/TEST-HammerCLI-AbstractCommand-options.xml +3 -3
  59. data/test/reports/TEST-HammerCLI-AbstractCommand-output.xml +7 -7
  60. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-remove-subcommand.xml +3 -3
  61. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand-.xml +4 -4
  62. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior-subcommand.xml +3 -3
  63. data/test/reports/TEST-HammerCLI-AbstractCommand-subcommand-behavior.xml +1 -1
  64. data/test/reports/TEST-HammerCLI-AbstractCommand.xml +3 -3
  65. data/test/reports/TEST-HammerCLI-Apipie-Command-options.xml +3 -3
  66. data/test/reports/TEST-HammerCLI-Apipie-Command-resource-defined.xml +2 -2
  67. data/test/reports/TEST-HammerCLI-Apipie-Command-setting-resources.xml +7 -7
  68. data/test/reports/TEST-HammerCLI-Apipie-Command.xml +2 -2
  69. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-aliasing-resources.xml +4 -4
  70. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-filtering-options.xml +5 -5
  71. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-required-options.xml +3 -3
  72. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-correct-normalizers.xml +2 -8
  73. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-hash-params.xml +3 -3
  74. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-with-one-simple-param.xml +5 -5
  75. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder.xml +1 -1
  76. data/test/reports/TEST-HammerCLI-Completer-command-completion.xml +12 -12
  77. data/test/reports/TEST-HammerCLI-Completer-option-value-completion.xml +6 -6
  78. data/test/reports/TEST-HammerCLI-Completer-subcommand-completion.xml +7 -7
  79. data/test/reports/TEST-HammerCLI-Completer.xml +1 -1
  80. data/test/reports/TEST-HammerCLI-CompleterLine-line-complete.xml +10 -10
  81. data/test/reports/TEST-HammerCLI-CompleterLine-splitting-words.xml +12 -12
  82. data/test/reports/TEST-HammerCLI-CompleterLine.xml +1 -1
  83. data/test/reports/TEST-HammerCLI-CompleterWord-complete-.xml +9 -9
  84. data/test/reports/TEST-HammerCLI-CompleterWord-quote.xml +5 -5
  85. data/test/reports/TEST-HammerCLI-CompleterWord-quoted-.xml +4 -4
  86. data/test/reports/TEST-HammerCLI-CompleterWord.xml +1 -1
  87. data/test/reports/TEST-HammerCLI-Connection.xml +8 -8
  88. data/test/reports/TEST-HammerCLI-ExceptionHandler.xml +8 -8
  89. data/test/reports/TEST-HammerCLI-I18n.xml +3 -3
  90. data/test/reports/TEST-HammerCLI-MainCommand-loading-context-password.xml +3 -3
  91. data/test/reports/TEST-HammerCLI-MainCommand-loading-context-username.xml +3 -3
  92. data/test/reports/TEST-HammerCLI-MainCommand-loading-context-verbose.xml +2 -2
  93. data/test/reports/TEST-HammerCLI-MainCommand-loading-context.xml +1 -1
  94. data/test/reports/TEST-HammerCLI-MainCommand.xml +1 -1
  95. data/test/reports/TEST-HammerCLI-Modules-find-by-name.xml +4 -4
  96. data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-not-found.xml +4 -4
  97. data/test/reports/TEST-HammerCLI-Modules-load-a-module-module-runtime-exception.xml +4 -4
  98. data/test/reports/TEST-HammerCLI-Modules-load-a-module-success.xml +5 -5
  99. data/test/reports/TEST-HammerCLI-Modules-load-a-module.xml +1 -1
  100. data/test/reports/TEST-HammerCLI-Modules-load-all-modules.xml +2 -4
  101. data/test/reports/TEST-HammerCLI-Modules-names.xml +4 -4
  102. data/test/reports/TEST-HammerCLI-Modules.xml +1 -1
  103. data/test/reports/TEST-HammerCLI-OptionBuilderContainer.0.xml +1 -5
  104. data/test/reports/TEST-HammerCLI-OptionBuilderContainer.xml +5 -1
  105. data/test/reports/TEST-HammerCLI-Options-Normalizers-abstract.xml +2 -2
  106. data/test/reports/TEST-HammerCLI-Options-Normalizers-bool.xml +13 -13
  107. data/test/reports/TEST-HammerCLI-Options-Normalizers-datetime.xml +6 -6
  108. data/test/reports/TEST-HammerCLI-Options-Normalizers-enum.xml +5 -5
  109. data/test/reports/TEST-HammerCLI-Options-Normalizers-enumlist.xml +8 -8
  110. data/test/reports/TEST-HammerCLI-Options-Normalizers-json-input.xml +5 -5
  111. data/test/reports/TEST-HammerCLI-Options-Normalizers-key-value-list.xml +6 -26
  112. data/test/reports/TEST-HammerCLI-Options-Normalizers-list.xml +5 -5
  113. data/test/reports/TEST-HammerCLI-Options-Normalizers.xml +1 -1
  114. data/test/reports/TEST-HammerCLI-Options-OptionDefinition-context.xml +2 -2
  115. data/test/reports/TEST-HammerCLI-Options-OptionDefinition-formatters.xml +3 -3
  116. data/test/reports/TEST-HammerCLI-Options-OptionDefinition.xml +1 -1
  117. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-error-messages.xml +5 -5
  118. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-messages.xml +3 -3
  119. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract-test-data-for-field.xml +5 -5
  120. data/test/reports/TEST-HammerCLI-Output-Adapter-Abstract.xml +6 -6
  121. data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection-show-ids.xml +2 -2
  122. data/test/reports/TEST-HammerCLI-Output-Adapter-Base-print-collection.xml +11 -11
  123. data/test/reports/TEST-HammerCLI-Output-Adapter-Base.xml +1 -1
  124. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-formatters.xml +3 -3
  125. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-collections.xml +4 -4
  126. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-fields-with-containers.xml +3 -3
  127. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection-handle-ids.xml +3 -3
  128. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-collection.xml +3 -3
  129. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues-print-message.xml +3 -3
  130. data/test/reports/TEST-HammerCLI-Output-Adapter-CSValues.xml +1 -1
  131. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-column-width.xml +5 -11
  132. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-formatters.xml +3 -3
  133. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-handle-ids.xml +3 -7
  134. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection-sort-columns.xml +2 -2
  135. data/test/reports/TEST-HammerCLI-Output-Adapter-Table-print-collection.xml +3 -3
  136. data/test/reports/TEST-HammerCLI-Output-Adapter-Table.xml +1 -1
  137. data/test/reports/TEST-HammerCLI-Output-Definition-empty-.xml +3 -3
  138. data/test/reports/TEST-HammerCLI-Output-Definition.xml +3 -3
  139. data/test/reports/TEST-HammerCLI-Output-Dsl-collection.xml +4 -4
  140. data/test/reports/TEST-HammerCLI-Output-Dsl-custom-fields.xml +3 -3
  141. data/test/reports/TEST-HammerCLI-Output-Dsl-fields.xml +5 -5
  142. data/test/reports/TEST-HammerCLI-Output-Dsl-label.xml +4 -4
  143. data/test/reports/TEST-HammerCLI-Output-Dsl-path-definition.xml +4 -4
  144. data/test/reports/TEST-HammerCLI-Output-Dsl.xml +2 -2
  145. data/test/reports/TEST-HammerCLI-Output-FieldFilter.xml +4 -4
  146. data/test/reports/TEST-HammerCLI-Output-Formatters-BooleanFormatter.xml +3 -3
  147. data/test/reports/TEST-HammerCLI-Output-Formatters-ColorFormatter.xml +2 -2
  148. data/test/reports/TEST-HammerCLI-Output-Formatters-DateFormatter.xml +3 -3
  149. data/test/reports/TEST-HammerCLI-Output-Formatters-FieldFormatter.xml +4 -4
  150. data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterContainer.xml +4 -4
  151. data/test/reports/TEST-HammerCLI-Output-Formatters-FormatterLibrary.xml +3 -3
  152. data/test/reports/TEST-HammerCLI-Output-Formatters-KeyValueFormatter.xml +4 -4
  153. data/test/reports/TEST-HammerCLI-Output-Formatters-ListFormatter.xml +4 -4
  154. data/test/reports/TEST-HammerCLI-Output-Formatters-LongTextFormatter.xml +4 -4
  155. data/test/reports/TEST-HammerCLI-Output-Output-adapters.xml +6 -6
  156. data/test/reports/TEST-HammerCLI-Output-Output-data.xml +5 -5
  157. data/test/reports/TEST-HammerCLI-Output-Output-formatters.xml +2 -2
  158. data/test/reports/TEST-HammerCLI-Output-Output-messages.xml +7 -7
  159. data/test/reports/TEST-HammerCLI-Output-Output.xml +1 -1
  160. data/test/reports/TEST-HammerCLI-Output-RecordCollection.xml +4 -4
  161. data/test/reports/TEST-HammerCLI-Settings-load-from-paths.xml +5 -5
  162. data/test/reports/TEST-HammerCLI-Settings.xml +10 -10
  163. data/test/reports/TEST-HammerCLI-ShellHistory-loading-old-history.xml +3 -3
  164. data/test/reports/TEST-HammerCLI-ShellHistory-saving-history.xml +5 -5
  165. data/test/reports/TEST-HammerCLI-ShellHistory.xml +1 -1
  166. data/test/reports/TEST-MiniTest-Spec.xml +1 -1
  167. data/test/reports/TEST-String-camelize.xml +3 -3
  168. data/test/reports/TEST-String-formatting.xml +6 -6
  169. data/test/reports/TEST-String-indent.xml +3 -3
  170. data/test/reports/{TEST-HammerCLI-interactive-.xml → TEST-String-interactive-.xml} +4 -4
  171. data/test/reports/TEST-String.xml +1 -1
  172. data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint-exist-.xml +4 -4
  173. data/test/reports/TEST-constraints-HammerCLI-Validator-AllConstraint.xml +1 -1
  174. data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint-exist-.xml +4 -4
  175. data/test/reports/TEST-constraints-HammerCLI-Validator-AnyConstraint.xml +1 -1
  176. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-exist-.xml +2 -2
  177. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-rejected.xml +4 -4
  178. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint-required.xml +4 -4
  179. data/test/reports/TEST-constraints-HammerCLI-Validator-BaseConstraint.xml +1 -1
  180. data/test/reports/TEST-constraints.xml +1 -1
  181. data/test/test_helper.rb +20 -0
  182. data/test/unit/output/formatters_test.rb +20 -3
  183. data/test/unit/test_helper.rb +1 -20
  184. metadata +195 -251
  185. data/test/reports/TEST-Fields-Label-display-.xml +0 -7
  186. data/test/reports/TEST-Fields-Label-display-blank-is-allowed.xml +0 -15
  187. data/test/reports/TEST-Fields-Label-display-blank-is-not-allowed.xml +0 -15
  188. data/test/reports/TEST-Fields-Label.xml +0 -7
  189. data/test/reports/TEST-HammerCLI-Apipie-Command-reload-apipie-cache.xml +0 -11
  190. data/test/reports/TEST-HammerCLI-Apipie-OptionBuilder-setting-referenced-resources.xml +0 -9
  191. data/test/reports/TEST-HammerCLI-Apipie-OptionDefinition-referenced-resource.xml +0 -13
  192. data/test/reports/TEST-HammerCLI-Apipie-OptionDefinition.xml +0 -7
  193. data/test/reports/TEST-HammerCLI-Defaults.xml +0 -19
  194. data/test/reports/TEST-HammerCLI-Options-Matcher.xml +0 -17
  195. data/test/reports/TEST-HammerCLI-Options-Normalizers-number.xml +0 -11
  196. data/test/reports/TEST-HammerCLI-Options-OptionDefinition-deprecated-options.xml +0 -11
  197. data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-collection-show-ids.xml +0 -9
  198. data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-collection.xml +0 -27
  199. data/test/reports/TEST-HammerCLI-Output-Adapter-Json-print-message.xml +0 -11
  200. data/test/reports/TEST-HammerCLI-Output-Adapter-Json.xml +0 -7
  201. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-collection-show-ids.xml +0 -9
  202. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-collection.xml +0 -27
  203. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml-print-message.xml +0 -11
  204. data/test/reports/TEST-HammerCLI-Output-Adapter-Yaml.xml +0 -7
  205. data/test/reports/TEST-HammerCLI-constant-path.xml +0 -15
  206. data/test/reports/TEST-HammerCLI.xml +0 -7
  207. data/test/reports/TEST-Logging-LogEvent-filtering.xml +0 -9
  208. data/test/reports/TEST-Logging-LogEvent.xml +0 -7
  209. data/test/reports/TEST-String-constantize.xml +0 -15
  210. data/test/reports/TEST-String-underscore.xml +0 -13
  211. data/test/reports/TEST-commands-defaults-add.xml +0 -21
  212. data/test/reports/TEST-commands-defaults-delete.xml +0 -11
  213. data/test/reports/TEST-commands-defaults-list.xml +0 -11
  214. data/test/reports/TEST-commands-defaults-providers.xml +0 -11
  215. data/test/reports/TEST-commands.xml +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed76c22f08106cd7634ad1fed540dcf36fd1c5df
4
- data.tar.gz: 9940232f3680440d7e8b86d6f102d1d03c87c8ba
3
+ metadata.gz: 33dccc5b0fb15f01c5a3b6bfb10f948b537d2a0d
4
+ data.tar.gz: 00204183081d15fd58aca9ec50bb82f57592720c
5
5
  SHA512:
6
- metadata.gz: 5d48b14bfa16dc4ecbf0cc41e6acd97984597ac2ffca027220b9f01dd7139f35bb1c040b99a44669ecca0e229c90a4017513779150d9019c6d8e8d6383c8386e
7
- data.tar.gz: d57b562879af67ef096b18e5010ca0ac158b6ee692275aeb4e26aaebfbdb5ec70ee46e82ec28f1e2f2e76754189d9946b032c4ce82211e8207c27d40e2870fc7
6
+ metadata.gz: cb778be8424eb378b46240b7903e30ebd40a1ff721091caf11d8ccbf7673e619a495a5f65e6227a49066e563a8a9bae04e19d9c637aa96f2fc510749d0eb3976
7
+ data.tar.gz: a0cb9c725c76a3a640b91ff36f75b5b745179749651a32c50ce7e957bbf2a680df966a4011d1ca72afed9638846b3e8714d8978ea6609c8edbc27bf0effbb9ff
data/doc/installation.md CHANGED
@@ -56,7 +56,7 @@ with descriptions.
56
56
 
57
57
  ### Plugins
58
58
 
59
- Plugins are disabled by default. To enable plugin create configuration file in ```cli.modules.d``` and add```:enable_plugin: true``` in it.
59
+ Plugins are disabled by default. To enable plugin create configuration file in ```cli.modules.d``` and add```:enable_module: true``` in it.
60
60
  Plugin specific configuration must be nested under plugin's name (without the ```hammer_cli_``` prefix).
61
61
 
62
62
  In the example we assume the gem ```hammer_cli_foreman``` with the Foreman plugin is installed. Then the plugin configuration
data/doc/release_notes.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Release notes
2
2
  =============
3
3
 
4
+ ### 0.6.0 (2016-02-25)
5
+ * Enable vertical formatting for lists ([#13874](http://projects.theforeman.org/issues/13874))
6
+ * Support for command testing moved to core ([#4118](http://projects.theforeman.org/issues/4118))
7
+ * Remove psych require from Gemfile ([#12797](http://projects.theforeman.org/issues/12797))
8
+ * Configuration doc on how to enable a plugin ([#13438](http://projects.theforeman.org/issues/13438))
9
+
4
10
  ### 0.5.1 (2015-12-15)
5
11
  * Minor release to fix wrongly packaged gem
6
12
 
@@ -93,6 +93,7 @@ module HammerCLI::Output
93
93
  end
94
94
 
95
95
  class ListFormatter < FieldFormatter
96
+ INDENT = " "
96
97
 
97
98
  def tags
98
99
  [:flat]
@@ -100,7 +101,12 @@ module HammerCLI::Output
100
101
 
101
102
  def format(list, field_params={})
102
103
  if list.is_a? Array
103
- list.join(", ")
104
+ separator = field_params.fetch(:separator, ', ')
105
+ new_line = field_params.fetch(:on_new_line, false)
106
+
107
+ list = list.join(separator)
108
+ list ="\n#{list.indent_with(INDENT)}" if new_line
109
+ list
104
110
  elsif list
105
111
  list.to_s
106
112
  else
@@ -0,0 +1,119 @@
1
+ module HammerCLI
2
+ module Testing
3
+ module CommandAssertions
4
+ class CommandExpectation
5
+ include MiniTest::Assertions
6
+
7
+ attr_accessor :expected_out, :expected_err, :expected_exit_code
8
+
9
+ def initialize(expected_out="", expected_err="", expected_exit_code=0)
10
+ @expected_out = expected_out
11
+ @expected_err = expected_err
12
+ @expected_exit_code = expected_exit_code
13
+ end
14
+
15
+ def assert_match(actual_result)
16
+ assert_equal_or_match @expected_err, actual_result.err
17
+ assert_equal_or_match @expected_out, actual_result.out
18
+ assert_exit_code_equal @expected_exit_code, actual_result.exit_code
19
+ end
20
+ end
21
+
22
+ class CommandRunResult
23
+ def initialize(out="", err="", exit_code=0)
24
+ @out = out
25
+ @err = err
26
+ @exit_code = exit_code
27
+ end
28
+ attr_accessor :out, :err, :exit_code
29
+ end
30
+
31
+ def run_cmd(options, context={}, cmd_class=HammerCLI::MainCommand)
32
+ result = CommandRunResult.new
33
+ result.out, result.err = capture_io do
34
+ result.exit_code = cmd_class.run('hammer', options, context)
35
+ end
36
+ result
37
+ end
38
+
39
+ def exit_code_map
40
+ return @exit_code_map unless @exit_code_map.nil?
41
+
42
+ hammer_exit_codes = HammerCLI.constants.select{|c| c.to_s.start_with?('EX_')}
43
+ @exit_code_map = hammer_exit_codes.inject({}) do |code_map, code|
44
+ code_map.update(HammerCLI.const_get(code) => code)
45
+ end
46
+ end
47
+
48
+ def assert_exit_code_equal(expected_code, actual_code)
49
+ expected_info = "#{exit_code_map[expected_code]} (#{expected_code})"
50
+ actual_info = "#{exit_code_map[actual_code]} (#{actual_code})"
51
+
52
+ msg = "The exit code was expected to be #{expected_info}, but it was #{actual_info}"
53
+ assert(expected_code == actual_code, msg)
54
+ end
55
+
56
+ def assert_cmd(expectation, actual_result)
57
+ expectation.assert_match(actual_result)
58
+ end
59
+
60
+ def assert_equal_or_match(expected, actual)
61
+ case expected
62
+ when String
63
+ assert_equal(expected, actual)
64
+ when MatcherBase
65
+ expected.assert_match(actual)
66
+ else
67
+ msg = actual
68
+ assert_match(expected, actual, msg)
69
+ end
70
+ end
71
+
72
+ def usage_error(command, message, heading=nil)
73
+ command = (['hammer'] + command).join(' ')
74
+ if heading.nil?
75
+ ["Error: #{message}",
76
+ "",
77
+ "See: '#{command} --help'",
78
+ ""].join("\n")
79
+ else
80
+ ["#{heading}:",
81
+ " Error: #{message}",
82
+ " ",
83
+ " See: '#{command} --help'",
84
+ ""].join("\n")
85
+ end
86
+ end
87
+
88
+ def common_error(command, message, heading=nil)
89
+ command = (['hammer'] + command).join(' ')
90
+ if heading.nil?
91
+ ["Error: #{message}",
92
+ ""].join("\n")
93
+ else
94
+ ["#{heading}:",
95
+ " Error: #{message}",
96
+ ""].join("\n")
97
+ end
98
+ end
99
+
100
+ def usage_error_result(command, message, heading=nil)
101
+ expected_result = CommandExpectation.new
102
+ expected_result.expected_err = usage_error(command, message, heading)
103
+ expected_result.expected_exit_code = HammerCLI::EX_USAGE
104
+ expected_result
105
+ end
106
+
107
+ def common_error_result(command, message, heading=nil)
108
+ expected_result = CommandExpectation.new
109
+ expected_result.expected_err = common_error(command, message, heading)
110
+ expected_result.expected_exit_code = HammerCLI::EX_SOFTWARE
111
+ expected_result
112
+ end
113
+
114
+ def success_result(message)
115
+ CommandExpectation.new(message)
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,19 @@
1
+ module HammerCLI
2
+ module Testing
3
+ module DataHelpers
4
+ def load_json(file_path, test_file_context=nil)
5
+ unless test_file_context.nil?
6
+ file_path = File.join(File.dirname(test_file_context), file_path)
7
+ end
8
+ JSON.parse(File.read(file_path))
9
+ end
10
+
11
+ def load_yaml(file_path, test_file_context=nil)
12
+ unless test_file_context.nil?
13
+ file_path = File.join(File.dirname(test_file_context), file_path)
14
+ end
15
+ YAML.load(File.read(file_path))
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,105 @@
1
+ module HammerCLI
2
+ module Testing
3
+ module OutputMatchers
4
+ class MatcherBase
5
+ include MiniTest::Assertions
6
+
7
+ def initialize(expected="")
8
+ @expected = expected
9
+ end
10
+
11
+ def assert_match(actual)
12
+ assert_equal(@expected, actual)
13
+ end
14
+ end
15
+
16
+ class FieldMatcher < MatcherBase
17
+ def initialize(label, value)
18
+ @expected = FieldMatcher.matcher(label, value)
19
+ end
20
+
21
+ def assert_match(actual)
22
+ message = "Regex /#{@expected.source}/ didn't match the output:\n#{actual}"
23
+ assert(@expected =~ actual, message)
24
+ end
25
+
26
+ def self.matcher(label, value)
27
+ Regexp.new(Regexp.quote(label) + ':[ ]+' + Regexp.quote(value))
28
+ end
29
+ end
30
+
31
+ class OutputMatcher < MatcherBase
32
+ attr_accessor :expected_lines
33
+
34
+ def initialize(expected="", options={})
35
+ @expected_lines = expected.is_a?(Array) ? expected : [expected]
36
+ @ignore_whitespace = options.fetch(:ignore_whitespace, true)
37
+ end
38
+
39
+ def assert_match(actual)
40
+ if @ignore_whitespace
41
+ expected_lines = strip_lines(@expected_lines)
42
+ actual = strip_lines(actual.split("\n")).join("\n")
43
+ else
44
+ expected_lines = @expected_lines
45
+ end
46
+ expected_lines = expected_lines.join("\n")
47
+
48
+ message = "Output didn't contain expected lines:\n" + diff(expected_lines, actual)
49
+ assert(actual.include?(expected_lines), message)
50
+ end
51
+
52
+ protected
53
+
54
+ def strip_lines(lines)
55
+ lines.map(&:rstrip)
56
+ end
57
+ end
58
+
59
+ class IndexMatcher < MatcherBase
60
+ def initialize(expected=[])
61
+ @line_matchers = []
62
+ expected.each do |line_expectation|
63
+ @line_matchers << IndexLineMatcher.new(line_expectation)
64
+ end
65
+ end
66
+
67
+ def assert_match(actual)
68
+ @line_matchers.each do |matcher|
69
+ matcher.assert_match(actual)
70
+ end
71
+ end
72
+ end
73
+
74
+ class IndexLineMatcher < MatcherBase
75
+ def initialize(expected=[])
76
+ @expected_values = expected
77
+ end
78
+
79
+ def assert_match(actual)
80
+ message = [
81
+ "Regex didn't match the output.",
82
+ "Expected regex:",
83
+ line_regexp.source,
84
+ "Expected fields:",
85
+ @expected_values.join(' | '),
86
+ "Actual output:",
87
+ actual
88
+ ].join("\n")
89
+
90
+ assert(line_regexp =~ actual, message)
91
+ end
92
+
93
+ protected
94
+
95
+ def line_regexp
96
+ re = @expected_values.map do |column|
97
+ Regexp.quote(column)
98
+ end.join('[ ]*\|[ ]*')
99
+ Regexp.new("[ ]*#{re}[ ]*")
100
+ end
101
+ end
102
+
103
+ end
104
+ end
105
+ end
@@ -1,5 +1,5 @@
1
1
  module HammerCLI
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.5.1'
3
+ @version ||= Gem::Version.new '0.6.0'
4
4
  end
5
5
  end
Binary file
@@ -5,7 +5,7 @@
5
5
  # Translators:
6
6
  # Christina Gurski <Gurski_christina@yahoo.de>, 2015
7
7
  # Dominic Cleal <dominic@cleal.org>, 2014
8
- # Ettore Atalan <atalanttore@googlemail.com>, 2014-2015
8
+ # Ettore Atalan <atalanttore@googlemail.com>, 2014-2016
9
9
  # simon11 <simon.stieger.98@live.de>, 2014
10
10
  # simon11 <simon.stieger.98@live.de>, 2014
11
11
  # Ulrich Habel <rhaen@pkgbox.de>, 2014
@@ -14,8 +14,8 @@ msgstr ""
14
14
  "Project-Id-Version: Foreman\n"
15
15
  "Report-Msgid-Bugs-To: \n"
16
16
  "POT-Creation-Date: 2015-12-08 08:56+0000\n"
17
- "PO-Revision-Date: 2015-12-11 09:09+0000\n"
18
- "Last-Translator: Lukáš Zapletal\n"
17
+ "PO-Revision-Date: 2016-01-17 22:48+0000\n"
18
+ "Last-Translator: Ettore Atalan <atalanttore@googlemail.com>\n"
19
19
  "Language-Team: German (http://www.transifex.com/foreman/foreman/language/de/)\n"
20
20
  "MIME-Version: 1.0\n"
21
21
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -65,35 +65,35 @@ msgstr ""
65
65
 
66
66
  #: ../lib/hammer_cli/defaults.rb:82
67
67
  msgid "Defaults management"
68
- msgstr ""
68
+ msgstr "Standardeinstellungsverwaltung"
69
69
 
70
70
  #: ../lib/hammer_cli/defaults_commands.rb:25
71
71
  msgid "List all the providers"
72
- msgstr ""
72
+ msgstr "Alle Anbieter auflisten"
73
73
 
74
74
  #: ../lib/hammer_cli/defaults_commands.rb:37
75
75
  msgid "Provider"
76
- msgstr ""
76
+ msgstr "Anbieter"
77
77
 
78
78
  #: ../lib/hammer_cli/defaults_commands.rb:38
79
79
  msgid "Supported defaults"
80
- msgstr ""
80
+ msgstr "Unterstützte Standardeinstellungen"
81
81
 
82
82
  #: ../lib/hammer_cli/defaults_commands.rb:39
83
83
  msgid "Description"
84
- msgstr ""
84
+ msgstr "Beschreibung"
85
85
 
86
86
  #: ../lib/hammer_cli/defaults_commands.rb:56
87
87
  msgid "List all the default parameters"
88
- msgstr ""
88
+ msgstr "Alle Standardparameter auflisten"
89
89
 
90
90
  #: ../lib/hammer_cli/defaults_commands.rb:67
91
91
  msgid "Parameter"
92
- msgstr ""
92
+ msgstr "Parameter"
93
93
 
94
94
  #: ../lib/hammer_cli/defaults_commands.rb:68
95
95
  msgid "Value"
96
- msgstr ""
96
+ msgstr "Wert"
97
97
 
98
98
  #: ../lib/hammer_cli/defaults_commands.rb:86
99
99
  msgid "Delete a default param"
@@ -101,19 +101,19 @@ msgstr ""
101
101
 
102
102
  #: ../lib/hammer_cli/defaults_commands.rb:87
103
103
  msgid "The name of the default option"
104
- msgstr ""
104
+ msgstr "Der Name der Standardoption"
105
105
 
106
106
  #: ../lib/hammer_cli/defaults_commands.rb:103
107
107
  msgid "Add a default parameter to config"
108
- msgstr ""
108
+ msgstr "Standardparameter zur Konfiguration hinzufügen"
109
109
 
110
110
  #: ../lib/hammer_cli/defaults_commands.rb:104
111
111
  msgid "The name of the default option (e.g. organization_id)."
112
- msgstr ""
112
+ msgstr "Der Name der Standardoption (z.B. organization_id)."
113
113
 
114
114
  #: ../lib/hammer_cli/defaults_commands.rb:105
115
115
  msgid "The value for the default option"
116
- msgstr ""
116
+ msgstr "Der Wert für die Standardoption"
117
117
 
118
118
  #: ../lib/hammer_cli/defaults_commands.rb:106
119
119
  msgid ""
@@ -145,7 +145,7 @@ msgstr ""
145
145
 
146
146
  #: ../lib/hammer_cli/defaults_commands.rb:147
147
147
  msgid "%{param} was deleted successfully."
148
- msgstr ""
148
+ msgstr "%{param} wurde erfolgreich gelöscht."
149
149
 
150
150
  #: ../lib/hammer_cli/defaults_commands.rb:151
151
151
  msgid "You must specify value or a provider name, cant specify both."
@@ -12,7 +12,7 @@
12
12
  # hpeters <hpeters@redhat.com>, 2015. #zanata
13
13
  msgid ""
14
14
  msgstr ""
15
- "Project-Id-Version: hammer-cli 0.4.0\n"
15
+ "Project-Id-Version: hammer-cli 0.6.0\n"
16
16
  "Report-Msgid-Bugs-To: \n"
17
17
  "PO-Revision-Date: 2015-04-27 11:50+0000\n"
18
18
  "Last-Translator: hpeters <hpeters@redhat.com>\n"
Binary file
@@ -5,7 +5,7 @@
5
5
  #
6
6
  msgid ""
7
7
  msgstr ""
8
- "Project-Id-Version: hammer-cli 0.4.0\n"
8
+ "Project-Id-Version: hammer-cli 0.6.0\n"
9
9
  "Report-Msgid-Bugs-To: \n"
10
10
  "PO-Revision-Date: 2014-03-04 16:38+0000\n"
11
11
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
Binary file
@@ -9,8 +9,8 @@ msgstr ""
9
9
  "Project-Id-Version: Foreman\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "POT-Creation-Date: 2015-12-08 08:56+0000\n"
12
- "PO-Revision-Date: 2015-12-11 09:09+0000\n"
13
- "Last-Translator: Lukáš Zapletal\n"
12
+ "PO-Revision-Date: 2015-12-15 15:11+0000\n"
13
+ "Last-Translator: Andi Chandler <andi@gowling.com>\n"
14
14
  "Language-Team: English (United Kingdom) (http://www.transifex.com/foreman/foreman/language/en_GB/)\n"
15
15
  "MIME-Version: 1.0\n"
16
16
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -56,99 +56,99 @@ msgstr "no value provided"
56
56
 
57
57
  #: ../lib/hammer_cli/defaults.rb:72
58
58
  msgid "Couldn't create %s please create the path before defaults are enabled."
59
- msgstr ""
59
+ msgstr "Couldn't create %s please create the path before defaults are enabled."
60
60
 
61
61
  #: ../lib/hammer_cli/defaults.rb:82
62
62
  msgid "Defaults management"
63
- msgstr ""
63
+ msgstr "Defaults management"
64
64
 
65
65
  #: ../lib/hammer_cli/defaults_commands.rb:25
66
66
  msgid "List all the providers"
67
- msgstr ""
67
+ msgstr "List all the providers"
68
68
 
69
69
  #: ../lib/hammer_cli/defaults_commands.rb:37
70
70
  msgid "Provider"
71
- msgstr ""
71
+ msgstr "Provider"
72
72
 
73
73
  #: ../lib/hammer_cli/defaults_commands.rb:38
74
74
  msgid "Supported defaults"
75
- msgstr ""
75
+ msgstr "Supported defaults"
76
76
 
77
77
  #: ../lib/hammer_cli/defaults_commands.rb:39
78
78
  msgid "Description"
79
- msgstr ""
79
+ msgstr "Description"
80
80
 
81
81
  #: ../lib/hammer_cli/defaults_commands.rb:56
82
82
  msgid "List all the default parameters"
83
- msgstr ""
83
+ msgstr "List all the default parameters"
84
84
 
85
85
  #: ../lib/hammer_cli/defaults_commands.rb:67
86
86
  msgid "Parameter"
87
- msgstr ""
87
+ msgstr "Parameter"
88
88
 
89
89
  #: ../lib/hammer_cli/defaults_commands.rb:68
90
90
  msgid "Value"
91
- msgstr ""
91
+ msgstr "Value"
92
92
 
93
93
  #: ../lib/hammer_cli/defaults_commands.rb:86
94
94
  msgid "Delete a default param"
95
- msgstr ""
95
+ msgstr "Delete a default param"
96
96
 
97
97
  #: ../lib/hammer_cli/defaults_commands.rb:87
98
98
  msgid "The name of the default option"
99
- msgstr ""
99
+ msgstr "The name of the default option"
100
100
 
101
101
  #: ../lib/hammer_cli/defaults_commands.rb:103
102
102
  msgid "Add a default parameter to config"
103
- msgstr ""
103
+ msgstr "Add a default parameter to config"
104
104
 
105
105
  #: ../lib/hammer_cli/defaults_commands.rb:104
106
106
  msgid "The name of the default option (e.g. organization_id)."
107
- msgstr ""
107
+ msgstr "The name of the default option (e.g. organisation_id)."
108
108
 
109
109
  #: ../lib/hammer_cli/defaults_commands.rb:105
110
110
  msgid "The value for the default option"
111
- msgstr ""
111
+ msgstr "The value for the default option"
112
112
 
113
113
  #: ../lib/hammer_cli/defaults_commands.rb:106
114
114
  msgid ""
115
115
  "The name of the provider providing the value. For list available providers "
116
116
  "see `hammer defaults providers`."
117
- msgstr ""
117
+ msgstr "The name of the provider providing the value. For list available providers see `hammer defaults providers`."
118
118
 
119
119
  #: ../lib/hammer_cli/defaults_commands.rb:134
120
120
  msgid ""
121
121
  "Added %{key_val} default-option with value that will be generated from the "
122
122
  "server."
123
- msgstr ""
123
+ msgstr "Added %{key_val} default-option with value that will be generated from the server."
124
124
 
125
125
  #: ../lib/hammer_cli/defaults_commands.rb:135
126
126
  msgid "Added %{key_val} default-option with value %{val_val}."
127
- msgstr ""
127
+ msgstr "Added %{key_val} default-option with value %{val_val}."
128
128
 
129
129
  #: ../lib/hammer_cli/defaults_commands.rb:139
130
130
  msgid ""
131
131
  "\"Provider #{namespace} was not found. See `hammer defaults providers` for "
132
132
  "available providers.\""
133
- msgstr ""
133
+ msgstr "\"Provider #{namespace} was not found. See `hammer defaults providers` for available providers.\""
134
134
 
135
135
  #: ../lib/hammer_cli/defaults_commands.rb:143
136
136
  msgid ""
137
137
  "The param name is not supported by provider. See `hammer defaults providers`"
138
138
  " for supported params."
139
- msgstr ""
139
+ msgstr "The param name is not supported by provider. See `hammer defaults providers` for supported params."
140
140
 
141
141
  #: ../lib/hammer_cli/defaults_commands.rb:147
142
142
  msgid "%{param} was deleted successfully."
143
- msgstr ""
143
+ msgstr "%{param} was deleted successfully."
144
144
 
145
145
  #: ../lib/hammer_cli/defaults_commands.rb:151
146
146
  msgid "You must specify value or a provider name, cant specify both."
147
- msgstr ""
147
+ msgstr "You must specify value or a provider name, cant specify both."
148
148
 
149
149
  #: ../lib/hammer_cli/defaults_commands.rb:155
150
150
  msgid "Couldn't find the requested param in %s."
151
- msgstr ""
151
+ msgstr "Couldn't find the requested param in %s."
152
152
 
153
153
  #: ../lib/hammer_cli/exception_handler.rb:62
154
154
  msgid "Error: %s"
@@ -324,7 +324,7 @@ msgstr "value must be a combination of '%s'"
324
324
 
325
325
  #: ../lib/hammer_cli/options/option_definition.rb:56
326
326
  msgid "Warning: Option %{option} is deprecated. %{message}"
327
- msgstr ""
327
+ msgstr "Warning: Option %{option} is deprecated. %{message}"
328
328
 
329
329
  #: ../lib/hammer_cli/options/option_definition.rb:80
330
330
  msgid "Can be specified multiple times. "
@@ -6,7 +6,7 @@
6
6
  # Andi Chandler <andi@gowling.com>, 2015
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: hammer-cli 0.4.0\n"
9
+ "Project-Id-Version: hammer-cli 0.6.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
11
  "PO-Revision-Date: 2015-08-30 02:01+0000\n"
12
12
  "Last-Translator: Andi Chandler <andi@gowling.com>\n"
Binary file
@@ -8,7 +8,7 @@
8
8
  # gguerrer <gguerrer@redhat.com>, 2015. #zanata
9
9
  msgid ""
10
10
  msgstr ""
11
- "Project-Id-Version: hammer-cli 0.4.0\n"
11
+ "Project-Id-Version: hammer-cli 0.6.0\n"
12
12
  "Report-Msgid-Bugs-To: \n"
13
13
  "PO-Revision-Date: 2015-04-27 06:26+0000\n"
14
14
  "Last-Translator: gguerrer <gguerrer@redhat.com>\n"
Binary file