summaryrefslogtreecommitdiff
path: root/spec/functions
AgeCommit message (Collapse)Author
2015-03-05Merge pull request #422 from cyberious/assert_privateTP Honey
Assert private
2015-03-05Add private function back and forward to assert_private with deprecation warningTravis Fields
2015-03-05Merge pull request #369 from rfugina/dirname_typecheckHunter Haugen
Dirname typecheck
2015-03-05Rename private() to assert_private()Franz Pletz
As mentioned in #270, private is a reserved keyword in the future parser which is to be released with Puppet 4. As it stands, this function is not useable with the future parser so it needs to renamed. This is a breaking change.
2015-03-05Merge pull request #375 from ↵Hunter Haugen
poikilotherm/feature/master/validate_integer_and_numeric (MODULES-560) Add new functions validate_numeric() and validate_integer().
2015-03-03Add support for hashes in the prefix functionStefan Goethals
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
2015-03-03URI.escape for the array case was incorrect.Bryon Roché
The previous commit to uriescape() changed the implementation to use the ruby default escape list for URI.escape(), but did not change the call triggered when uriescape() was called on an array, triggering ruby errors.
2015-03-03Merge pull request #407 from adamcrews/ceiling_functionMorgan Haskel
Add a ceiling function to complement the floor function.
2015-03-02Loosen the restrictions of upcase and allow for recursion of the objects and ↵Travis Fields
only worry if the object responds to upcase
2015-02-25Add Hash to upcaseTravis Fields
2015-02-14(MODULES-1771) Don't modify input to is_domain_name()Sean Millichamp
Fix is_domain_name() so it dup's its incoming argument to avoid changing the original with a later chomp!
2015-02-12(MODULES-1738) Don't modify global seed in fqdn_rotate()Eli Young
As per puppetlabs/puppet@292233c, this leaves the global seed in a deterministic state, which is bad. Puppet::Util.deterministic_rand() exists to avoid running into this issue, but is only present starting in Puppet 3.2.0.
2015-02-01Add a ceiling function to complement the floor function.Adam Crews
2015-01-07(MODULES-1473) Deprecate type() function for new parserHunter Haugen
The `type()` function will cease to work on the new parser because 'type' is a reserved keyword. The `type3x()` function may be used to continue similar functionality, but will be deprecated in favor of the built-in typing system. The `type_of()` function has been included to introspect types in the new parser.
2014-12-19MODULES-1606 add ability to pass array to delete for items to deleteTravis Fields
2014-12-18(MODULES-1582) Specs for the new % placeholderPeter Souter
These specs are pretty much the same as the originals, but now check that the output has the correct replacement for file location
2014-12-17Merge pull request #372 from ↵Morgan Haskel
poikilotherm/feature/master/validate_absolute_path_allow_arrays Allow array of pathes in validate_absolute_path
2014-12-17Added type checks for dirname(), and additional testsRob Fugina
2014-12-04Add new functions validate_numeric() and validate_integer().Oliver Bertuch
2014-12-04(MODULES-444) - Check for accepting > 2 argsPeter Souter
2014-12-04(MODULES-444) Change test to > 2 argumentsPeter Souter
Also add extra test for just 1 argument
2014-12-04(MODULES-444) Add specs for new behaviourPeter Souter
`concat` can now take multiple arguments
2014-11-25Allow array of pathes in validate_absolute_pathOliver Bertuch
2014-11-13Merge pull request #319 from Spredzy/member_array_in_arrayHunter Haugen
(MODULES-1329) Allow member to look for array
2014-11-12(MODULES-1329) Allow member function to look for arrayYanis Guenane
Currently, the member function allows one to only find if a variable is part of an array. Sometimes it is useful to find if an array is part of a bigger array for validation purpose.
2014-11-12Add range tests for numeric with step and mixed argumentsErik Dalén
2014-11-12Make the range function work with integersErik Dalén
This is needed for the future parser which actually treats numbers as numbers and strings as strings. With this patch you can use range(1,5) instead of having to quote them like range('1','5').
2014-11-07Merge pull request #343 from zacharyalexstern/fix_to_bytesTravis Fields
Added correct converstions for PB and EB.
2014-10-28Added correct converstions for PB and EB.Zachary Alex Stern
* We were converting Exabytes to bytes as Petabytes. * Updated tests to cover ever unit. * Added note that we're going by the old, inaccurate definitions of Kilobytes, Megabytes, etc, in that we treat them as powers of 2.
2014-09-22(MODULES-707) chomp() fails because generate() no longer returns a stringMark Chappell
We need to use unless value.is_a?(String) || value.is_a?(Array) rather than klass = value.class unless [String, Array].include?(klass) because the klass version enforces type checking which is too strict, and does not allow us to accept objects wich have extended String (or Array). For example, generate() function now returns Puppet::Util::Execution::ProcessOutput which is just a very simple extension of String. While this in it's self was not intentional (PUP-2306) it is not unreasonable to cope with objects which extend Strings
2014-07-31Introduce test for array destructionSpencer Krum
It was discovered that the concat array modifies the arrays passed to it as an argument as a side effect. This test will ensure that doesn't happen again.
2014-06-11Add private() functionRaphaël Pinson
2014-06-04Convert specs to RSpec 2.99.0 syntax with TranspecAshley Penney
This conversion is done by Transpec 2.2.1 with the following command: transpec spec/functions * 345 conversions from: obj.should to: expect(obj).to * 122 conversions from: == expected to: eq(expected) * 85 conversions from: lambda { }.should to: expect { }.to * 22 conversions from: be_true to: be_truthy * 16 conversions from: be_false to: be_falsey * 11 conversions from: pending to: skip * 9 conversions from: it { should ... } to: it { is_expected.to ... } * 5 conversions from: =~ [1, 2] to: match_array([1, 2]) * 2 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.should_not to: expect(obj).not_to For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-05-08Move unit tests to spec/functionsHunter Haugen
rspec-puppet matchers are defined for tests which exist in spec/functions, but the function unit tests lived in spec/unit/puppet/parser/functions. This moves them to the correct place for using rspec-puppet
2014-05-07Move the 4 misplaced testsHunter Haugen
2014-05-07Add the missing shebangs and fix the wrong ones for rpmlint to stop ↵Andrea Veri
complaining loudly
2014-03-30(MODULES-603) Add defaults arguments to ensure_packages()Yanis Guenane
Without this patch one can not specify package resource specific parameters. All the ensure_packages() function does it makes sure the named packages are installed. This patch allows one to pass default as a second argument and allow greater flexibility on packages installations. Use case like the following are now possible : * ensure_packages(['r10k', 'serverspec'], {'provider' => 'gem'}) * ensure_packages(['ntp'], {'require' => 'Exec[foobar]'})
2014-03-08Numerous changes to update testing gems.Ashley Penney
This work updates a number of Gems to the latest versions (rspec, rspec-puppet), and updates and tweaks a bunch of tests to work with the updated gems.
2014-01-15(maint) Update ensure_package specs to confirm expected behaviorAdrien Thebo
The previous behavior of the tests checked the behavior of the underlying functions library when called with no arguments; this commit updates the tests to conform to the functions API and test what happens when a function is called with no args.
2014-01-15Allow a single argument, rather than an arrayTomas Doran
2013-08-29(maint) Fix failing spec test with Puppet 3.3.0-rc2Jeff McCune
Without this patch the stdlib spec tests are failing against recent versions of Puppet. The root cause of this problem is a change in the behavior of create_resources in Puppet 6baa57b. The change in behavior caused the :name key to be omitted from the hash returned by Puppet::Parser::Resource#to_hash which in turn is causing the test failure. This patch addresses the problem by updating the test to match the description of the example. Only the attribute :ensure is checked instead of the full hash itself.
2013-05-06Refactor ensure_resource expectationsAlex Cline
This splits out the ensure_resource expectations into separate blocks for clarity. Per adrienthebo's recommendation.
2013-05-03(#20548) Allow an array of resource titles to be passed into the ↵Alex Cline
ensure_resource function This patch allows an array of resource titles to be passed into the ensure_resource function. Each item in the array will be checked for existence and will be created if it doesn't already exist.
2013-01-09Add getparam function to get defined resource parametersJaka Hudoklin
As far as i know there's no other puppet-dsl-like way to get parameter of defined resource, so that's why i implemented getparam function, which takes resource reference and parameter name and returns parameter value. Here's another example why this function is really useful: define config($path, $config_param1, $config_param2) { } define example_resource($config) { $path = getparam($config, "path") notice("Path is $path") } define example_resource2($example_resource, $config = getparam($example_resource, "config")) { $config_param1 = getparam($config, "config_param1") notice("Config parameter is $config_param1") } define example_resource3($example_resource, $config = getparam($example_resource, "config")) { $config_param2 = getparam($config, "config_param2") notice("Config parameter is $config_param2") } class test_getparam { config { "config_instance": path => "/some/config/path", config_param1 => "someconfigtext1", config_param2 => "someconfigtext2", } example_resource { "example_resource_instance": config => Config["config_instance"] } example_resource2 { "example_resource_instance": example_resource => Example_resource["example_resource_instance"] } example_resource3 { "example_resource_instance": example_resource => Example_resource2["example_resource_instance"] } } class { "test_getparam": }
2012-11-27Add example behaviors for ensure_packages() functionJeff McCune
Without this patch the ensure_packages() function has no rspec behavior examples. This patch fixes the problem by filling out a spec file with expected behaviors I could think of.
2012-10-25re-formattingDan Bode
This commit refactors to ensure 80 character lines.
2012-10-25Handle undef for parameter argumentDan Bode
This commit adds better handling of the case where undef is passed as the parameter value. This works by converting '' into []
2012-10-25Add function ensure_resource and defined_with_paramsDan Bode
This commit adds 2 new functions with unit tests. defined_with_params works similarily to puppet's defined function, except it allows you to also specify a hash of params. defined_with_params will return true if a resource also exists that matches the specified type/title (just like with defined) as well as all of the specified params. ensure_resource is a function that basically combines defined_with_params with create_resources to conditionally create resources only if the specified resource (title, type, params) does not already exist. These functions are created to serve as an alternative to using defined as follows: if ! defined(Package['some_package']) { package { 'some_package': ensure => present, } The issue with this usage is that there is no guarentee about what parameters were set in the previous definition of the package that made its way into the catalog. ensure_resource could be used instead, as: ensure_resource('package', 'some_package', { 'ensure' => 'present' }) This will creat the package resources only if another resource does not exist with the specified parameters.