puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (276) hide show
  1. data/Gemfile +0 -3
  2. data/MAINTAINERS +76 -0
  3. data/README.md +0 -6
  4. data/Rakefile +2 -2
  5. data/lib/puppet/agent.rb +3 -3
  6. data/lib/puppet/application/apply.rb +1 -1
  7. data/lib/puppet/configurer.rb +2 -2
  8. data/lib/puppet/data_providers.rb +1 -0
  9. data/lib/puppet/data_providers/data_adapter.rb +1 -0
  10. data/lib/puppet/data_providers/data_function_support.rb +1 -0
  11. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
  12. data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
  13. data/lib/puppet/data_providers/hiera_config.rb +1 -0
  14. data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
  15. data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
  16. data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
  17. data/lib/puppet/data_providers/hiera_support.rb +1 -2
  18. data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
  19. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
  20. data/lib/puppet/defaults.rb +20 -1
  21. data/lib/puppet/environments.rb +5 -2
  22. data/lib/puppet/face/catalog.rb +1 -1
  23. data/lib/puppet/face/epp.rb +57 -11
  24. data/lib/puppet/face/module/install.rb +6 -6
  25. data/lib/puppet/functions.rb +23 -24
  26. data/lib/puppet/functions/alert.rb +14 -0
  27. data/lib/puppet/functions/binary_file.rb +25 -0
  28. data/lib/puppet/functions/break.rb +22 -0
  29. data/lib/puppet/functions/contain.rb +33 -0
  30. data/lib/puppet/functions/crit.rb +14 -0
  31. data/lib/puppet/functions/debug.rb +14 -0
  32. data/lib/puppet/functions/emerg.rb +14 -0
  33. data/lib/puppet/functions/epp.rb +1 -1
  34. data/lib/puppet/functions/err.rb +14 -0
  35. data/lib/puppet/functions/find_file.rb +31 -0
  36. data/lib/puppet/functions/include.rb +21 -0
  37. data/lib/puppet/functions/info.rb +14 -0
  38. data/lib/puppet/functions/new.rb +1 -1
  39. data/lib/puppet/functions/next.rb +23 -0
  40. data/lib/puppet/functions/notice.rb +14 -0
  41. data/lib/puppet/functions/regsubst.rb +12 -16
  42. data/lib/puppet/functions/require.rb +37 -0
  43. data/lib/puppet/functions/return.rb +22 -0
  44. data/lib/puppet/functions/strftime.rb +35 -0
  45. data/lib/puppet/functions/warning.rb +14 -0
  46. data/lib/puppet/generate/models/type/type.rb +4 -0
  47. data/lib/puppet/generate/templates/type/pcore.erb +2 -1
  48. data/lib/puppet/indirector/face.rb +6 -1
  49. data/lib/puppet/network/http/error.rb +2 -2
  50. data/lib/puppet/network/http/handler.rb +2 -2
  51. data/lib/puppet/node/environment.rb +11 -0
  52. data/lib/puppet/parser/ast.rb +5 -0
  53. data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
  54. data/lib/puppet/parser/compiler.rb +29 -1
  55. data/lib/puppet/parser/functions.rb +6 -0
  56. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  57. data/lib/puppet/parser/functions/binary_file.rb +24 -0
  58. data/lib/puppet/parser/functions/break.rb +39 -0
  59. data/lib/puppet/parser/functions/contain.rb +7 -15
  60. data/lib/puppet/parser/functions/defined.rb +2 -2
  61. data/lib/puppet/parser/functions/dig.rb +1 -1
  62. data/lib/puppet/parser/functions/each.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +2 -2
  64. data/lib/puppet/parser/functions/filter.rb +1 -1
  65. data/lib/puppet/parser/functions/find_file.rb +28 -0
  66. data/lib/puppet/parser/functions/hiera.rb +4 -4
  67. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  68. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  69. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  70. data/lib/puppet/parser/functions/include.rb +4 -8
  71. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  72. data/lib/puppet/parser/functions/lest.rb +1 -1
  73. data/lib/puppet/parser/functions/lookup.rb +4 -2
  74. data/lib/puppet/parser/functions/map.rb +1 -1
  75. data/lib/puppet/parser/functions/match.rb +1 -1
  76. data/lib/puppet/parser/functions/new.rb +414 -18
  77. data/lib/puppet/parser/functions/next.rb +38 -0
  78. data/lib/puppet/parser/functions/reduce.rb +1 -1
  79. data/lib/puppet/parser/functions/regsubst.rb +4 -2
  80. data/lib/puppet/parser/functions/require.rb +4 -27
  81. data/lib/puppet/parser/functions/return.rb +71 -0
  82. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  83. data/lib/puppet/parser/functions/scanf.rb +13 -8
  84. data/lib/puppet/parser/functions/slice.rb +1 -1
  85. data/lib/puppet/parser/functions/split.rb +1 -1
  86. data/lib/puppet/parser/functions/step.rb +1 -1
  87. data/lib/puppet/parser/functions/strftime.rb +185 -0
  88. data/lib/puppet/parser/functions/then.rb +1 -1
  89. data/lib/puppet/parser/functions/type.rb +1 -1
  90. data/lib/puppet/parser/functions/with.rb +3 -3
  91. data/lib/puppet/parser/resource.rb +8 -5
  92. data/lib/puppet/parser/scope.rb +1 -1
  93. data/lib/puppet/plugins/configuration.rb +8 -0
  94. data/lib/puppet/plugins/data_providers.rb +1 -0
  95. data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
  96. data/lib/puppet/plugins/data_providers/registry.rb +1 -0
  97. data/lib/puppet/pops.rb +4 -0
  98. data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
  99. data/lib/puppet/pops/evaluator/closure.rb +81 -12
  100. data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
  101. data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
  102. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
  103. data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
  104. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
  105. data/lib/puppet/pops/functions/dispatch.rb +9 -2
  106. data/lib/puppet/pops/functions/dispatcher.rb +3 -1
  107. data/lib/puppet/pops/functions/function.rb +19 -2
  108. data/lib/puppet/pops/issues.rb +9 -0
  109. data/lib/puppet/pops/label_provider.rb +2 -2
  110. data/lib/puppet/pops/loader/loader.rb +17 -0
  111. data/lib/puppet/pops/loader/static_loader.rb +0 -41
  112. data/lib/puppet/pops/lookup.rb +12 -0
  113. data/lib/puppet/pops/lookup/context.rb +86 -0
  114. data/lib/puppet/pops/lookup/explainer.rb +46 -6
  115. data/lib/puppet/pops/lookup/invocation.rb +19 -0
  116. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  117. data/lib/puppet/pops/model/factory.rb +20 -8
  118. data/lib/puppet/pops/model/model_label_provider.rb +3 -0
  119. data/lib/puppet/pops/model/model_meta.rb +2 -0
  120. data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
  121. data/lib/puppet/pops/parser/egrammar.ra +11 -6
  122. data/lib/puppet/pops/parser/eparser.rb +1112 -1086
  123. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  124. data/lib/puppet/pops/pcore.rb +1 -0
  125. data/lib/puppet/pops/puppet_stack.rb +3 -3
  126. data/lib/puppet/pops/resource/param.rb +5 -1
  127. data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
  128. data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
  129. data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
  130. data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
  131. data/lib/puppet/pops/serialization/deserializer.rb +5 -1
  132. data/lib/puppet/pops/serialization/extension.rb +2 -0
  133. data/lib/puppet/pops/serialization/json.rb +76 -26
  134. data/lib/puppet/pops/serialization/serializer.rb +5 -1
  135. data/lib/puppet/pops/serialization/time_factory.rb +2 -1
  136. data/lib/puppet/pops/time/timespan.rb +718 -0
  137. data/lib/puppet/pops/time/timestamp.rb +148 -0
  138. data/lib/puppet/pops/types/p_binary_type.rb +220 -0
  139. data/lib/puppet/pops/types/p_object_type.rb +12 -6
  140. data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
  141. data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
  142. data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
  143. data/lib/puppet/pops/types/string_converter.rb +62 -0
  144. data/lib/puppet/pops/types/type_asserter.rb +1 -1
  145. data/lib/puppet/pops/types/type_calculator.rb +17 -3
  146. data/lib/puppet/pops/types/type_factory.rb +35 -1
  147. data/lib/puppet/pops/types/type_formatter.rb +64 -11
  148. data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
  149. data/lib/puppet/pops/types/type_parser.rb +18 -4
  150. data/lib/puppet/pops/types/types.rb +98 -63
  151. data/lib/puppet/pops/validation.rb +9 -1
  152. data/lib/puppet/pops/validation/checker4_0.rb +7 -0
  153. data/lib/puppet/property.rb +1 -1
  154. data/lib/puppet/provider.rb +3 -6
  155. data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
  156. data/lib/puppet/provider/mount/parsed.rb +18 -4
  157. data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
  158. data/lib/puppet/provider/package/gem.rb +6 -1
  159. data/lib/puppet/provider/package/pip.rb +0 -1
  160. data/lib/puppet/provider/package/pkg.rb +5 -1
  161. data/lib/puppet/provider/package/pkgng.rb +1 -1
  162. data/lib/puppet/provider/package/yum.rb +10 -0
  163. data/lib/puppet/provider/service/launchd.rb +1 -0
  164. data/lib/puppet/provider/user/directoryservice.rb +6 -6
  165. data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
  166. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  167. data/lib/puppet/resource.rb +54 -12
  168. data/lib/puppet/resource/capability_finder.rb +15 -9
  169. data/lib/puppet/resource/catalog.rb +25 -6
  170. data/lib/puppet/resource/type.rb +3 -1
  171. data/lib/puppet/settings.rb +1 -1
  172. data/lib/puppet/settings/environment_conf.rb +12 -4
  173. data/lib/puppet/syntax_checkers/base64.rb +41 -0
  174. data/lib/puppet/syntax_checkers/json.rb +0 -2
  175. data/lib/puppet/transaction.rb +6 -0
  176. data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
  177. data/lib/puppet/transaction/report.rb +7 -2
  178. data/lib/puppet/type.rb +2 -1
  179. data/lib/puppet/type/file/checksum.rb +1 -0
  180. data/lib/puppet/type/file/content.rb +4 -4
  181. data/lib/puppet/type/mount.rb +44 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +1 -1
  183. data/lib/puppet/type/tidy.rb +3 -0
  184. data/lib/puppet/type/user.rb +12 -6
  185. data/lib/puppet/util/log.rb +25 -0
  186. data/lib/puppet/util/plist.rb +8 -3
  187. data/lib/puppet/version.rb +1 -1
  188. data/lib/puppet_x.rb +7 -1
  189. data/spec/integration/application/apply_spec.rb +118 -0
  190. data/spec/integration/parser/compiler_spec.rb +28 -0
  191. data/spec/integration/parser/pcore_resource_spec.rb +40 -3
  192. data/spec/integration/provider/mount_spec.rb +2 -1
  193. data/spec/integration/util/windows/principal_spec.rb +2 -2
  194. data/spec/integration/util/windows/registry_spec.rb +4 -4
  195. data/spec/lib/puppet_spec/compiler.rb +5 -1
  196. data/spec/lib/puppet_spec/unindent.rb +5 -0
  197. data/spec/shared_contexts/types_setup.rb +6 -0
  198. data/spec/shared_examples/rhel_package_provider.rb +16 -0
  199. data/spec/spec_helper.rb +1 -0
  200. data/spec/unit/agent_spec.rb +11 -0
  201. data/spec/unit/application/lookup_spec.rb +94 -3
  202. data/spec/unit/capability_spec.rb +22 -0
  203. data/spec/unit/configurer_spec.rb +8 -0
  204. data/spec/unit/face/epp_face_spec.rb +22 -3
  205. data/spec/unit/functions/assert_type_spec.rb +3 -3
  206. data/spec/unit/functions/binary_file_spec.rb +46 -0
  207. data/spec/unit/functions/break_spec.rb +89 -0
  208. data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
  209. data/spec/unit/functions/find_file_spec.rb +69 -0
  210. data/spec/unit/functions/include_spec.rb +175 -0
  211. data/spec/unit/functions/logging_spec.rb +54 -0
  212. data/spec/unit/functions/lookup_spec.rb +3 -3
  213. data/spec/unit/functions/new_spec.rb +105 -5
  214. data/spec/unit/functions/next_spec.rb +93 -0
  215. data/spec/unit/functions/require_spec.rb +83 -0
  216. data/spec/unit/functions/return_spec.rb +105 -0
  217. data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
  218. data/spec/unit/functions/strftime_spec.rb +152 -0
  219. data/spec/unit/functions4_spec.rb +22 -0
  220. data/spec/unit/indirector/face_spec.rb +10 -2
  221. data/spec/unit/network/http/error_spec.rb +1 -2
  222. data/spec/unit/network/http/handler_spec.rb +6 -5
  223. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  224. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  225. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  226. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  227. data/spec/unit/parser/functions/lookup_spec.rb +1 -1
  228. data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
  229. data/spec/unit/parser/functions/split_spec.rb +1 -1
  230. data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
  231. data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
  232. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
  233. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
  234. data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
  235. data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
  236. data/spec/unit/pops/lookup/context_spec.rb +149 -0
  237. data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
  238. data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
  239. data/spec/unit/pops/puppet_stack_spec.rb +1 -1
  240. data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
  241. data/spec/unit/pops/serialization/packer_spec.rb +34 -14
  242. data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
  243. data/spec/unit/pops/time/timespan_spec.rb +121 -0
  244. data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
  245. data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
  246. data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
  247. data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
  248. data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
  249. data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
  250. data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
  251. data/spec/unit/pops/types/string_converter_spec.rb +89 -0
  252. data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
  253. data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
  254. data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
  255. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
  256. data/spec/unit/pops/types/type_parser_spec.rb +87 -4
  257. data/spec/unit/pops/types/types_spec.rb +1 -1
  258. data/spec/unit/pops/validator/validator_spec.rb +23 -0
  259. data/spec/unit/provider/mount/parsed_spec.rb +47 -29
  260. data/spec/unit/provider/package/pkg_spec.rb +109 -99
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
  262. data/spec/unit/provider/user/aix_spec.rb +1 -1
  263. data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
  264. data/spec/unit/resource/capability_finder_spec.rb +29 -7
  265. data/spec/unit/resource/catalog_spec.rb +127 -0
  266. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  267. data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
  268. data/spec/unit/transaction/persistence_spec.rb +1 -6
  269. data/spec/unit/transaction/report_spec.rb +23 -0
  270. data/spec/unit/transaction_spec.rb +38 -0
  271. data/spec/unit/type/mount_spec.rb +5 -0
  272. data/spec/unit/util/plist_spec.rb +14 -2
  273. metadata +71 -12
  274. data/spec/integration/parser/functions/require_spec.rb +0 -43
  275. data/spec/unit/parser/functions/include_spec.rb +0 -55
  276. data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -0,0 +1,311 @@
1
+ require 'spec_helper'
2
+ require 'puppet/pops'
3
+ require 'puppet_spec/compiler'
4
+
5
+ module Puppet::Pops
6
+ module Types
7
+ describe 'Timestamp type' do
8
+
9
+ it 'is normalized in a Variant' do
10
+ t = TypeFactory.variant(TypeFactory.timestamp('2015-03-01', '2016-01-01'), TypeFactory.timestamp('2015-11-03', '2016-12-24')).normalize
11
+ expect(t).to be_a(PTimestampType)
12
+ expect(t).to eql(TypeFactory.timestamp('2015-03-01', '2016-12-24'))
13
+ end
14
+
15
+ context 'when used in Puppet expressions' do
16
+ include PuppetSpec::Compiler
17
+ it 'is equal to itself only' do
18
+ code = <<-CODE
19
+ $t = Timestamp
20
+ notice(Timestamp =~ Type[Timestamp])
21
+ notice(Timestamp == Timestamp)
22
+ notice(Timestamp < Timestamp)
23
+ notice(Timestamp > Timestamp)
24
+ CODE
25
+ expect(eval_and_collect_notices(code)).to eq(%w(true true false false))
26
+ end
27
+
28
+ context "when parameterized" do
29
+ it 'is equal other types with the same parameterization' do
30
+ code = <<-CODE
31
+ notice(Timestamp['2015-03-01', '2016-01-01'] == Timestamp['2015-03-01', '2016-01-01'])
32
+ notice(Timestamp['2015-03-01', '2016-01-01'] != Timestamp['2015-11-03', '2016-12-24'])
33
+ CODE
34
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
35
+ end
36
+
37
+ it 'using just one parameter is the same as using that parameter twice' do
38
+ code = <<-CODE
39
+ notice(Timestamp['2015-03-01'] == Timestamp['2015-03-01', '2015-03-01'])
40
+ CODE
41
+ expect(eval_and_collect_notices(code)).to eq(%w(true))
42
+ end
43
+
44
+ it 'orders parameterized types based on range inclusion' do
45
+ code = <<-CODE
46
+ notice(Timestamp['2015-03-01', '2015-09-30'] < Timestamp['2015-02-01', '2015-10-30'])
47
+ notice(Timestamp['2015-03-01', '2015-09-30'] > Timestamp['2015-02-01', '2015-10-30'])
48
+ CODE
49
+ expect(eval_and_collect_notices(code)).to eq(%w(true false))
50
+ end
51
+ end
52
+
53
+ context 'a Timestamp instance' do
54
+ it 'can be created from a string' do
55
+ code = <<-CODE
56
+ $o = Timestamp('2015-03-01')
57
+ notice($o)
58
+ notice(type($o))
59
+ CODE
60
+ expect(eval_and_collect_notices(code)).to eq(['2015-03-01T00:00:00.000 UTC', "Timestamp['2015-03-01T00:00:00.000 UTC']"])
61
+ end
62
+
63
+ it 'can be created from a string and format' do
64
+ code = <<-CODE
65
+ $o = Timestamp('Sunday, 28 August, 2016', '%A, %d %B, %Y')
66
+ notice($o)
67
+ CODE
68
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T00:00:00.000 UTC'])
69
+ end
70
+
71
+ it 'can be created from a string, format, and a timezone' do
72
+ code = <<-CODE
73
+ $o = Timestamp('Sunday, 28 August, 2016', '%A, %d %B, %Y', 'EST')
74
+ notice($o)
75
+ CODE
76
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T05:00:00.000 UTC'])
77
+ end
78
+
79
+ it 'can be not be created from a string, format with timezone designator, and a timezone' do
80
+ code = <<-CODE
81
+ $o = Timestamp('Sunday, 28 August, 2016 UTC', '%A, %d %B, %Y %z', 'EST')
82
+ notice($o)
83
+ CODE
84
+ expect { eval_and_collect_notices(code) }.to raise_error(
85
+ /Using a Timezone designator in format specification is mutually exclusive to providing an explicit timezone argument/)
86
+ end
87
+
88
+ it 'can be created from a hash with string and format' do
89
+ code = <<-CODE
90
+ $o = Timestamp({ string => 'Sunday, 28 August, 2016', format => '%A, %d %B, %Y' })
91
+ notice($o)
92
+ CODE
93
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T00:00:00.000 UTC'])
94
+ end
95
+
96
+ it 'can be created from a hash with string, format, and a timezone' do
97
+ code = <<-CODE
98
+ $o = Timestamp({ string => 'Sunday, 28 August, 2016', format => '%A, %d %B, %Y', timezone => 'EST' })
99
+ notice($o)
100
+ CODE
101
+ expect(eval_and_collect_notices(code)).to eq(['2016-08-28T05:00:00.000 UTC'])
102
+ end
103
+
104
+ it 'can be created from a string and array of formats' do
105
+ code = <<-CODE
106
+ $fmts = [
107
+ '%A, %d %B, %Y at %r',
108
+ '%b %d, %Y, %l:%M %P',
109
+ '%y-%m-%d %H:%M:%S %z'
110
+ ]
111
+ notice(Timestamp('Sunday, 28 August, 2016 at 12:15:00 PM', $fmts))
112
+ notice(Timestamp('Jul 24, 2016, 1:20 am', $fmts))
113
+ notice(Timestamp('16-06-21 18:23:15 UTC', $fmts))
114
+ CODE
115
+ expect(eval_and_collect_notices(code)).to eq(
116
+ ['2016-08-28T12:15:00.000 UTC', '2016-07-24T01:20:00.000 UTC', '2016-06-21T18:23:15.000 UTC'])
117
+ end
118
+
119
+ it 'can be created from a string, array of formats, and a timezone' do
120
+ code = <<-CODE
121
+ $fmts = [
122
+ '%A, %d %B, %Y at %r',
123
+ '%b %d, %Y, %l:%M %P',
124
+ '%y-%m-%d %H:%M:%S'
125
+ ]
126
+ notice(Timestamp('Sunday, 28 August, 2016 at 12:15:00 PM', $fmts, 'CET'))
127
+ notice(Timestamp('Jul 24, 2016, 1:20 am', $fmts, 'CET'))
128
+ notice(Timestamp('16-06-21 18:23:15', $fmts, 'CET'))
129
+ CODE
130
+ expect(eval_and_collect_notices(code)).to eq(
131
+ ['2016-08-28T11:15:00.000 UTC', '2016-07-24T00:20:00.000 UTC', '2016-06-21T17:23:15.000 UTC'])
132
+ end
133
+
134
+ it 'can be created from a integer that represents seconds since epoch' do
135
+ code = <<-CODE
136
+ $o = Timestamp(1433116800)
137
+ notice(Integer($o) == 1433116800)
138
+ notice($o == Timestamp('2015-06-01T00:00:00 UTC'))
139
+ CODE
140
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
141
+ end
142
+
143
+ it 'can be created from a float that represents seconds with fraction since epoch' do
144
+ code = <<-CODE
145
+ $o = Timestamp(1433116800.123456)
146
+ notice(Float($o) == 1433116800.123456)
147
+ notice($o == Timestamp('2015-06-01T00:00:00.123456 UTC'))
148
+ CODE
149
+ expect(eval_and_collect_notices(code)).to eq(%w(true true))
150
+ end
151
+
152
+ it 'matches the appropriate parameterized type' do
153
+ code = <<-CODE
154
+ $o = Timestamp('2015-05-01')
155
+ notice(assert_type(Timestamp['2015-03-01', '2015-09-30'], $o))
156
+ CODE
157
+ expect(eval_and_collect_notices(code)).to eq(['2015-05-01T00:00:00.000 UTC'])
158
+ end
159
+
160
+ it 'does not match an inappropriate parameterized type' do
161
+ code = <<-CODE
162
+ $o = Timestamp('2015-05-01')
163
+ notice(assert_type(Timestamp['2016-03-01', '2016-09-30'], $o) |$e, $a| { 'nope' })
164
+ CODE
165
+ expect(eval_and_collect_notices(code)).to eq(['nope'])
166
+ end
167
+
168
+ it 'can be compared to other instances' do
169
+ code = <<-CODE
170
+ $o1 = Timestamp('2015-05-01')
171
+ $o2 = Timestamp('2015-06-01')
172
+ $o3 = Timestamp('2015-06-01')
173
+ notice($o1 > $o3)
174
+ notice($o1 >= $o3)
175
+ notice($o1 < $o3)
176
+ notice($o1 <= $o3)
177
+ notice($o1 == $o3)
178
+ notice($o1 != $o3)
179
+ notice($o2 > $o3)
180
+ notice($o2 < $o3)
181
+ notice($o2 >= $o3)
182
+ notice($o2 <= $o3)
183
+ notice($o2 == $o3)
184
+ notice($o2 != $o3)
185
+ CODE
186
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false true false false true true true false))
187
+ end
188
+
189
+ it 'can be compared to integer that represents seconds since epoch' do
190
+ code = <<-CODE
191
+ $o1 = Timestamp('2015-05-01')
192
+ $o2 = Timestamp('2015-06-01')
193
+ $o3 = 1433116800
194
+ notice($o1 > $o3)
195
+ notice($o1 >= $o3)
196
+ notice($o1 < $o3)
197
+ notice($o1 <= $o3)
198
+ notice($o2 > $o3)
199
+ notice($o2 < $o3)
200
+ notice($o2 >= $o3)
201
+ notice($o2 <= $o3)
202
+ CODE
203
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
204
+ end
205
+
206
+ it 'integer that represents seconds since epoch can be compared to it' do
207
+ code = <<-CODE
208
+ $o1 = 1430438400
209
+ $o2 = 1433116800
210
+ $o3 = Timestamp('2015-06-01')
211
+ notice($o1 > $o3)
212
+ notice($o1 >= $o3)
213
+ notice($o1 < $o3)
214
+ notice($o1 <= $o3)
215
+ notice($o2 > $o3)
216
+ notice($o2 < $o3)
217
+ notice($o2 >= $o3)
218
+ notice($o2 <= $o3)
219
+ CODE
220
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
221
+ end
222
+
223
+ it 'is equal to integer that represents seconds since epoch' do
224
+ code = <<-CODE
225
+ $o1 = Timestamp('2015-06-01T00:00:00 UTC')
226
+ $o2 = 1433116800
227
+ notice($o1 == $o2)
228
+ notice($o1 != $o2)
229
+ notice(Integer($o1) == $o2)
230
+ CODE
231
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
232
+ end
233
+
234
+ it 'integer that represents seconds is equal to it' do
235
+ code = <<-CODE
236
+ $o1 = 1433116800
237
+ $o2 = Timestamp('2015-06-01T00:00:00 UTC')
238
+ notice($o1 == $o2)
239
+ notice($o1 != $o2)
240
+ notice($o1 == Integer($o2))
241
+ CODE
242
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
243
+ end
244
+
245
+ it 'can be compared to float that represents seconds with fraction since epoch' do
246
+ code = <<-CODE
247
+ $o1 = Timestamp('2015-05-01T00:00:00.123456789 UTC')
248
+ $o2 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
249
+ $o3 = 1433116800.123456789
250
+ notice($o1 > $o3)
251
+ notice($o1 >= $o3)
252
+ notice($o1 < $o3)
253
+ notice($o1 <= $o3)
254
+ notice($o2 > $o3)
255
+ notice($o2 < $o3)
256
+ notice($o2 >= $o3)
257
+ notice($o2 <= $o3)
258
+ CODE
259
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
260
+ end
261
+
262
+ it 'float that represents seconds with fraction since epoch can be compared to it' do
263
+ code = <<-CODE
264
+ $o1 = 1430438400.123456789
265
+ $o2 = 1433116800.123456789
266
+ $o3 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
267
+ notice($o1 > $o3)
268
+ notice($o1 >= $o3)
269
+ notice($o1 < $o3)
270
+ notice($o1 <= $o3)
271
+ notice($o2 > $o3)
272
+ notice($o2 < $o3)
273
+ notice($o2 >= $o3)
274
+ notice($o2 <= $o3)
275
+ CODE
276
+ expect(eval_and_collect_notices(code)).to eq(%w(false false true true false false true true))
277
+ end
278
+
279
+ it 'is equal to float that represents seconds with fraction since epoch' do
280
+ code = <<-CODE
281
+ $o1 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
282
+ $o2 = 1433116800.123456789
283
+ notice($o1 == $o2)
284
+ notice($o1 != $o2)
285
+ notice(Float($o1) == $o2)
286
+ CODE
287
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
288
+ end
289
+
290
+ it 'float that represents seconds with fraction is equal to it' do
291
+ code = <<-CODE
292
+ $o1 = 1433116800.123456789
293
+ $o2 = Timestamp('2015-06-01T00:00:00.123456789 UTC')
294
+ notice($o1 == $o2)
295
+ notice($o1 != $o2)
296
+ notice($o1 == Float($o2))
297
+ CODE
298
+ expect(eval_and_collect_notices(code)).to eq(%w(true false true))
299
+ end
300
+
301
+ it 'it cannot be compared to a Timespan' do
302
+ code = <<-CODE
303
+ notice(Timestamp() > Timespan(3))
304
+ CODE
305
+ expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /Timestamps are only comparable to Timestamps, Integers, and Floats/)
306
+ end
307
+ end
308
+ end
309
+ end
310
+ end
311
+ end
@@ -107,7 +107,7 @@ module Puppet::Pops
107
107
  version => '1.0.0',
108
108
  OBJECT
109
109
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
110
- /expected a value for key 'pcore_version'/)
110
+ /expects a value for key 'pcore_version'/)
111
111
  end
112
112
 
113
113
  it 'version is missing' do
@@ -115,7 +115,7 @@ module Puppet::Pops
115
115
  pcore_version => '1.0.0',
116
116
  OBJECT
117
117
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
118
- /expected a value for key 'version'/)
118
+ /expects a value for key 'version'/)
119
119
  end
120
120
 
121
121
  it 'the version is an invalid semantic version' do
@@ -150,7 +150,7 @@ module Puppet::Pops
150
150
  name_authority => 'not a valid URI'
151
151
  OBJECT
152
152
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
153
- /entry 'name_authority' expected a match for Pattern\[.*\], got 'not a valid URI'/m)
153
+ /entry 'name_authority' expects a match for Pattern\[.*\], got 'not a valid URI'/m)
154
154
  end
155
155
 
156
156
  context 'the types map' do
@@ -161,7 +161,7 @@ module Puppet::Pops
161
161
  types => {}
162
162
  OBJECT
163
163
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
164
- /entry 'types' expected size to be at least 1, got 0/)
164
+ /entry 'types' expects size to be at least 1, got 0/)
165
165
  end
166
166
 
167
167
  it 'is not a map' do
@@ -171,7 +171,7 @@ module Puppet::Pops
171
171
  types => []
172
172
  OBJECT
173
173
  expect { parse_type_set('MySet', ts) }.to raise_error(Puppet::Error,
174
- /entry 'types' expected a Hash value, got Array/)
174
+ /entry 'types' expects a Hash value, got Array/)
175
175
  end
176
176
 
177
177
  it 'contains values that are not types' do
@@ -195,7 +195,7 @@ module Puppet::Pops
195
195
  }
196
196
  OBJECT
197
197
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
198
- /key of entry 'car' expected a match for Pattern\[\/\\A\[A-Z\]\\w\*\\z\/\], got 'car'/)
198
+ /key of entry 'car' expects a match for Pattern\[\/\\A\[A-Z\]\\w\*\\z\/\], got 'car'/)
199
199
  end
200
200
  end
201
201
 
@@ -207,7 +207,7 @@ module Puppet::Pops
207
207
  references => {}
208
208
  OBJECT
209
209
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
210
- /entry 'references' expected size to be at least 1, got 0/)
210
+ /entry 'references' expects size to be at least 1, got 0/)
211
211
  end
212
212
 
213
213
  it 'is not a hash' do
@@ -217,7 +217,7 @@ module Puppet::Pops
217
217
  references => []
218
218
  OBJECT
219
219
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
220
- /entry 'references' expected a Hash value, got Array/)
220
+ /entry 'references' expects a Hash value, got Array/)
221
221
  end
222
222
 
223
223
  it 'contains something other than reference initialization maps' do
@@ -227,7 +227,7 @@ module Puppet::Pops
227
227
  references => {Ref => 2}
228
228
  OBJECT
229
229
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
230
- /entry 'references' entry 'Ref' expected a Struct value, got Integer/)
230
+ /entry 'references' entry 'Ref' expects a Struct value, got Integer/)
231
231
  end
232
232
 
233
233
  it 'contains several initialization that refers to the same TypeSet' do
@@ -266,7 +266,7 @@ module Puppet::Pops
266
266
  references => { Ref => { name => 'X' } }
267
267
  OBJECT
268
268
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
269
- /entry 'references' entry 'Ref' expected a value for key 'version_range'/)
269
+ /entry 'references' entry 'Ref' expects a value for key 'version_range'/)
270
270
  end
271
271
 
272
272
  it 'has no name' do
@@ -276,7 +276,7 @@ module Puppet::Pops
276
276
  references => { Ref => { version_range => '1.x' } }
277
277
  OBJECT
278
278
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
279
- /entry 'references' entry 'Ref' expected a value for key 'name'/)
279
+ /entry 'references' entry 'Ref' expects a value for key 'name'/)
280
280
  end
281
281
 
282
282
  it 'has a name that is not a QRef' do
@@ -286,7 +286,7 @@ module Puppet::Pops
286
286
  references => { Ref => { name => 'cars', version_range => '1.x' } }
287
287
  OBJECT
288
288
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
289
- /entry 'references' entry 'Ref' entry 'name' expected a match for Pattern\[\/\\A\[A-Z\]\[\\w\]\*\(\?:::\[A-Z\]\[\\w\]\*\)\*\\z\/\], got 'cars'/)
289
+ /entry 'references' entry 'Ref' entry 'name' expects a match for Pattern\[\/\\A\[A-Z\]\[\\w\]\*\(\?:::\[A-Z\]\[\\w\]\*\)\*\\z\/\], got 'cars'/)
290
290
  end
291
291
 
292
292
  it 'has a version_range that is not a valid SemVer range' do
@@ -306,7 +306,7 @@ module Puppet::Pops
306
306
  references => { 'cars' => { name => 'X', version_range => '1.x' } }
307
307
  OBJECT
308
308
  expect { parse_type_set('MySet', ts) }.to raise_error(TypeAssertionError,
309
- /entry 'references' key of entry 'cars' expected a match for Pattern\[\/\\A\[A-Z\]\\w\*\\z\/\], got 'cars'/)
309
+ /entry 'references' key of entry 'cars' expects a match for Pattern\[\/\\A\[A-Z\]\\w\*\\z\/\], got 'cars'/)
310
310
  end
311
311
  end
312
312
  end
@@ -81,14 +81,14 @@ describe 'Puppet Ruby Generator' do
81
81
  it 'will perform type assertion of the arguments' do
82
82
  expect { first.create('Bob Builder', '52') }.to(
83
83
  raise_error(TypeAssertionError,
84
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got String')
84
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
85
85
  )
86
86
  end
87
87
 
88
88
  it 'will not accept nil as given value for an optional parameter that does not accept nil' do
89
89
  expect { first.create('Bob Builder', nil) }.to(
90
90
  raise_error(TypeAssertionError,
91
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got Undef')
91
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
92
92
  )
93
93
  end
94
94
 
@@ -128,7 +128,7 @@ describe 'Puppet Ruby Generator' do
128
128
  it 'does not accept an initializer where optional values are nil and type does not accept nil' do
129
129
  expect { first.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
130
130
  raise_error(TypeAssertionError,
131
- "MyModule::FirstGenerated initializer had wrong type, entry 'age' expected an Integer value, got Undef")
131
+ "MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
132
132
  )
133
133
  end
134
134
  end
@@ -205,14 +205,14 @@ describe 'Puppet Ruby Generator' do
205
205
  it 'will perform type assertion of the arguments' do
206
206
  expect { PuppetSpec::RubyGenerator::FirstGenerated.create('Bob Builder', '52') }.to(
207
207
  raise_error(TypeAssertionError,
208
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got String')
208
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
209
209
  )
210
210
  end
211
211
 
212
212
  it 'will not accept nil as given value for an optional parameter that does not accept nil' do
213
213
  expect { PuppetSpec::RubyGenerator::FirstGenerated.create('Bob Builder', nil) }.to(
214
214
  raise_error(TypeAssertionError,
215
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got Undef')
215
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
216
216
  )
217
217
  end
218
218
 
@@ -252,7 +252,7 @@ describe 'Puppet Ruby Generator' do
252
252
  it 'does not accept an initializer where optional values are nil and type does not accept nil' do
253
253
  expect { PuppetSpec::RubyGenerator::FirstGenerated.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
254
254
  raise_error(TypeAssertionError,
255
- "MyModule::FirstGenerated initializer had wrong type, entry 'age' expected an Integer value, got Undef")
255
+ "MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
256
256
  )
257
257
  end
258
258
  end
@@ -389,14 +389,14 @@ describe 'Puppet Ruby Generator' do
389
389
  it 'will perform type assertion of the arguments' do
390
390
  expect { first.create('Bob Builder', '52') }.to(
391
391
  raise_error(TypeAssertionError,
392
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got String')
392
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
393
393
  )
394
394
  end
395
395
 
396
396
  it 'will not accept nil as given value for an optional parameter that does not accept nil' do
397
397
  expect { first.create('Bob Builder', nil) }.to(
398
398
  raise_error(TypeAssertionError,
399
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got Undef')
399
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
400
400
  )
401
401
  end
402
402
 
@@ -436,7 +436,7 @@ describe 'Puppet Ruby Generator' do
436
436
  it 'does not accept an initializer where optional values are nil and type does not accept nil' do
437
437
  expect { first.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
438
438
  raise_error(TypeAssertionError,
439
- "MyModule::FirstGenerated initializer had wrong type, entry 'age' expected an Integer value, got Undef")
439
+ "MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
440
440
  )
441
441
  end
442
442
  end
@@ -519,14 +519,14 @@ describe 'Puppet Ruby Generator' do
519
519
  it 'will perform type assertion of the arguments' do
520
520
  expect { PuppetSpec::RubyGenerator::My::FirstGenerated.create('Bob Builder', '52') }.to(
521
521
  raise_error(TypeAssertionError,
522
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got String')
522
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got String')
523
523
  )
524
524
  end
525
525
 
526
526
  it 'will not accept nil as given value for an optional parameter that does not accept nil' do
527
527
  expect { PuppetSpec::RubyGenerator::My::FirstGenerated.create('Bob Builder', nil) }.to(
528
528
  raise_error(TypeAssertionError,
529
- 'MyModule::FirstGenerated[age] had wrong type, expected an Integer value, got Undef')
529
+ 'MyModule::FirstGenerated[age] has wrong type, expects an Integer value, got Undef')
530
530
  )
531
531
  end
532
532
 
@@ -566,7 +566,7 @@ describe 'Puppet Ruby Generator' do
566
566
  it 'does not accept an initializer where optional values are nil and type does not accept nil' do
567
567
  expect { PuppetSpec::RubyGenerator::My::FirstGenerated.from_hash('name' => 'Bob Builder', 'age' => nil) }.to(
568
568
  raise_error(TypeAssertionError,
569
- "MyModule::FirstGenerated initializer had wrong type, entry 'age' expected an Integer value, got Undef")
569
+ "MyModule::FirstGenerated initializer has wrong type, entry 'age' expects an Integer value, got Undef")
570
570
  )
571
571
  end
572
572
  end