summaryrefslogtreecommitdiff
path: root/spec
AgeCommit message (Collapse)Author
2013-09-18(#22214): close content file before executing checkscriptsgzijl
Right now validation seems to be done against zero byte generated temp files. We need to close the file before executing validation against it.
2013-09-18Merge pull request #184 from lmello/fix_bug_20681_delete_undef_valuesAdrien Thebo
delete_undef_values function fix bug #20681
2013-09-18(#20681) fix behaviour of delete_undef_valuesLeonardo Rodrigues de Mello
The issue #20681 describe the error of delete() function removing the elements from the origin array/hash/string. This issue affected other delete functions. Because ruby delete and delete_if functions make destructive changes to the origin array/hash. The delete_undef_values removed elements from the origin array/hash and this is not the desired behaviour. To solve this, we should dup or clone the array/hash before using the delete or delete_if ruby functions. We should also check if args[0] is not nil before using dup, since dup on nil raises exception. This fix the problem and add unit tests, so we could enforce this behaviour and prevent regressions.
2013-09-17Merge pull request #183 from lmello/fix_bug_20681_delete_atAdrien Thebo
delete_at added spec to check against bug #20681
2013-09-17Merge pull request #182 from lmello/fix_bug_20681_delete_valuesAdrien Thebo
delete_values() fix bug #20681.
2013-09-17Merge pull request #185 from lmello/refactor_16498Adrien Thebo
(#16498) Added unit test for loadyaml function.
2013-09-17(#16498) Added unit test for loadyaml function.Leonardo Rodrigues de Mello
As stated on the issue #16498, it would be great to have unit tests for all the functions. Function loadyaml was missing a unit test. This commit added the unit test to loadyaml function.
2013-09-17Merge pull request #178 from lmello/fix_bug_20681Adrien Thebo
bug # 20681 delete() function should not remove elements from original list
2013-09-17(#20681) delete_at function unit test against issueLeonardo Rodrigues de Mello
The issue #20681 describe the error of delete() function removing the elements from the origin array/hash/string. This issue affected the other delete functions. The delete_at function is not afected by this bug, but it did not had the unit test to check against it. I had added the unit test so we could prevent regressions on the future and also have better test coverage.
2013-09-17(#20681) fix behaviour of delete_valuesLeonardo Rodrigues de Mello
The issue #20681 describe the error of delete() function removing the elements from the origin array/hash/string. This issue affected other delete functions. Because ruby delete and delete_if functions make destructive changes to the origin array/hash. The delete_undef_values removed elements from the origin hash and this is not the desired behaviour. To solve this, we should dup or clone the hash before using the delete or delete_if ruby functions. This fix the problem and add unit tests, so we could enforce this behaviour and prevent regressions.
2013-09-16Merge pull request #179 from lmello/function_pick_error_msgAdrien Thebo
enhanced the error message of pick function.
2013-09-16bug # 20681 delete() function should not remove elements from original listLeonardo Rodrigues de Mello
The setup: list with 3 elements, delete one: $test_list = [‘a’, ‘b’, ‘c’] $test_deleted = delete($test_list, ‘a’) Print out the elements in ‘test_deleted’: notify { ‘group_output2’: withpath => true, name => “$cfeng::test_deleted”, } Notice: /Stage[main]/Syslog/Notify[group_output2]/message: bc Good! Run-on output shows that ‘a’ was deleted Print out the elements in ‘test_list’: notify { ‘group_output1’: withpath => true, name => “$cfeng::test_list”, } Notice: /Stage[main]/Syslog/Notify[group_output1]/message: bc WHAT!? 'a' was deleted from ‘test_list’ as well! Expected abc as output! This behaviour is confirmed for string, hash and array. This is fixed on this commit, I had added two spec tests to cover that cases. bug #20681 spec test for delete() function. I had forgot in the last commit the spec test for hash in the delete function. bug # 20681 delete() function change aproach. Instead of rejecting elements from the original list, we use collection = arguments[0].dup . then latter we could continue to use delete and gsub! on collection without impact on original argument. this is a better solution than the previous one, and works on ruby 1.8.7, 1.9.3 and 2.0.0. The previous solution does not work on ruby 1.8.7. delete function remove typo whitespace. fix typo whitespaces.
2013-09-16enhanced the error message of pick function.Leonardo Rodrigues de Mello
When pick function fail return a better error message like the other stdlib functions, indicating that the error is on function pick. This would help people that see the error to identity it is related to a incorrect use of stdlib function pick, instead of having to grep all puppet libraries and manifests source for the old message. I had also changed the spec test. pick function change spec as suggested GH-179 Fix the spec test to use expect {}.to instead of lambda {}.should as explained by Adrienthebo. "Using expect { }.to is preferred over lambda { }.should. In addition it's best practice to do a string match against the error message to ensure that we're catching the right error, instead of any error of the right type." Also fixed a typo on the error message, it was missing one space. pick function stylish fix as suggested on GH179
2013-08-29(maint) Improve the tests and readability of file_lineJeff McCune
Without this patch the implementation of the file_line provider is a bit convoluted with respect to the newly introduced "after" parameter. This patch addresses the problem by separating out the concerns of each case into their own methods of handling the behavior with the match parameter, handling the behavior with the after parameter, or simply appending the line.
2013-08-29Update file_line resource to support 'after'.Dan Prince
When adding new lines to a file the 'after' option can be useful when you need to insert file lines into the middle of a file. This is particularly helpful when using file_line with sectioned config files. NOTE: the after option only works when adding new lines. If you are updating an existing (matched) line it will simply modify it in place. This assumes it was in the right place to begin with.
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-08-28Merge pull request #172 from ptomulik/fix/delete_xxx_specAdrien Thebo
small fix to delete_values_spec.rb and README.markdown
2013-08-14small fix to delete_values_spec.rb and README.markdownPaweł Tomulik
2013-08-12(maint) refactor validate_slength testsAdrien Thebo
2013-08-06Merge pull request #167 from mhellmic/minlengthAdrien Thebo
extend the validate_slength function to accept a minimum length
2013-08-06changed the validate_slength function to accept a min lengthMartin Hellmich
An optional third parameter can be given a min length. The function then only passes successfully, if all strings are in the range min_length <= string <= max_length update and fix function and unit tests the check for the minlength has to be written differently because 0 values should be possible. We now check a) if the input is convertible, and throw a ParseError and b) if the input .is_a?(Numeric) and ask for a positive number it's not as clean as for maxlength, but keeps a similar behaviour refined the error checking for the min length try to convert to Integer(args[2]) and fail, if it's not possible changed the tests accordingly to the new parameter checking
2013-08-05added delete_values() and delete_undef_values() functionsPaweł Tomulik
2013-07-22Adjust to use default URI.escape escape listTomas Doran
Conform to RFC per comments on: https://github.com/puppetlabs/puppetlabs-stdlib/pull/164 Conflicts: lib/puppet/parser/functions/uriescape.rb spec/unit/puppet/parser/functions/uriescape_spec.rb
2013-07-11(#21416) Allow file_line to match multiple linesAlex O'Rielly
Without this commit the file_line type will outright fail if multiple lines match the given regex. This commit allows the file_line type and provider to optionally match and modify all matching lines. Changeset rebased into a single commit by Adrien Thebo <adrien@puppetlabs.com>
2013-06-07Merge pull request #158 from wfarr/validate_ipAdrien Thebo
[#20862] Add functions to validate ipv4 and ipv6 addresses
2013-05-28(maint) Remove syntax decoration from range_specAdrien Thebo
2013-05-28(maint) Clean up range_spec error expectationAdrien Thebo
Replace `lambda` with `expect` for making an error expectation Add an explicit error message in expectation
2013-05-28(maint) Use present tense in range_spec messagesAdrien Thebo
2013-05-28(maint) split up range spec with describe blocksAdrien Thebo
2013-05-28Merge remote-tracking branch 'pr/56' into pull-56Adrien Thebo
Conflicts: lib/puppet/parser/functions/range.rb spec/unit/puppet/parser/functions/range_spec.rb
2013-05-24Adding base64 functionfiddyspence
Adding base64 function and spec test. Included a bonus fix to validate_slength_spec.rb to put the expectation message in the right place.
2013-05-22Don't run certain tests under 1.8.7Will Farrington
2013-05-22Update ipv6 examplesWill Farrington
2013-05-22Add functions to validate ipv4 and ipv6 addressesWill Farrington
2013-05-15Merge pull request #155 from AlexCline/feature/master/array_comparison_functionsHailee Kenney
(#20684) Add array comparison functions, difference, intersection and union
2013-05-15Merge pull request #147 from mhellmic/masterAdrien Thebo
don't fail on undef variable in merge
2013-05-13(#20684) Add array comparison functions, difference, intersection and union.Alex Cline
Included is code, tests and documentation for the difference, intersection and union functions for comparing arrays.
2013-05-08Added rspec tests for the new behaviour of merge accepting empty stringsMartin Hellmich
added test that '' is accepted changed a test that a number is correctly rejected with a type error
2013-05-07Merge branch 'fix_facts_dot_d_with_pe'Jeff McCune
* fix_facts_dot_d_with_pe: (maint) Indent facter_dot_d with 2 spaces (#20582) Restore facter_dot_d to stdlib for PE users Revert "Revert "Revert "Merge branch 'hkenney-ticket/master/2157_remove_facts_dot_d'""" (maint) Update Gemfile with GEM_FACTER_VERSION closes #153
2013-05-07(#20582) Restore facter_dot_d to stdlib for PE usersJeff McCune
Without this patch Puppet Enterprise users who install the most recent version of stdlib lose the ability to resolve certain facts critical to the operation of Puppet Enterprise. These facts are defined externally in the file `/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`. As an example, Puppet Enterprise catalogs fail to compile if the `fact_stomp_server`, and `fact_stomp_port` facts are not defined. `facter_dot_d` was removed from stdlib version 4 because Facter version 1.7 now supports external facts defined in `/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`. Puppet Enterprise does not yet include Facter 1.7, however. The most recent PE release, 2.8.1, includes Facter 1.6.17. With this version of Facter, users who replace the version of stdlib that ships with PE with the most recent version from the Forge will lose the ability to resolve facts from `/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt`. This patch addresses the problem by detecting if Facter version < 1.7 is loaded. If so, then the facter_dot_d.rb facts will be defined using the stdlib custom fact. If Facter >= 1.7 is being used then stdlib will not define external facts.
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-05-02Add a dirname functionRaphaël Pinson
2013-04-11Add behavior example for anchor refresh propagationJeff McCune
Without this patch we don't have a spec test to make sure the anchor resource type passes notify events along. This patch addresses the problem by using RSpec Puppet to build a catalog, apply the catalog, then pull a resource out of the transaction and make sure the resource was triggered.
2013-04-10(maint) Add the behavior for count() with arrays and hashesJeff McCune
Without this patch the expected behavior of the count() function when dealing with an out of bound array index and with a hash key that does not exist is implicitly encoded in the spec examples. This is a problem because the expected behavior is not clear for something similar to the following example: node default { $ary = [ 1, 2, 3 ] $ary_undef = $ary[100] $hsh = { 'one' => 1 } $hsh_undef = $hsh['dne'] $count = count(['hi', $ary_undef, $hsh_undef]) notice "Count is ${count}" } This patch addresses the problem by making the expected behavior explicit in the examples.
2013-04-10Add a count functionErik Dalén
Similar to the ruby count method on arrays.
2013-04-03(#19998) Implement any2arrayAmos Shapira
This change is to implement a new function "any2array", which will take any argument or arguments and create an array which contains it. If the argument is a single array then it will be returned as-is. If the argument is a single hash then it will be converted into an array. Otherwise (if there are more than one argument, or the only argument is not an array or a hash) the function will return an array containing all the arguments.
2013-04-01Cleanup per adrianthebo suggestionsSteve Huff
* use Float() to process string arguments * get rid of doubly nested arrays * removing needless ternary operator * improving error message handling
2013-03-29(19864) num2bool match fixSteve Huff
This is a bit more heavy-handed than I might like, but it does appear to do the right things: * accepts numeric input appropriately, truncating floats * matches string input against a regex, then coerces number-looking strings to int * makes a best effort to coerce anything else to a string, then subjects it to the same treatment * raises an error in the event of incorrect number of arguments or non-number-looking strings I've also included some additional unit tests.
2013-03-29Reworked number-handling logicSteve Huff
No more coercing to String and regex matching. Instead, we now coerce to Integer at the beginning or raise an error if we cannot coerce to Integer. A consequence of this change is that the function will now accept blatantly non-numeric strings as input, and return false. This seems a bit goofy to me, but it's how String#to_i works. If we really don't like this, then I'm open to suggestions.