summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/type/file_line_spec.rb
AgeCommit message (Collapse)Author
2017-09-29(maint) Clarify docs and add new testsAlex Harvey
Based on a Stack Overflow question, it was noted that the documentation for `file_line` isn't complete and the underlying behaviour somewhat confusing. https://stackoverflow.com/questions/46468922/how-to-change-the-contents-of-a-file-by-using-puppet/46473458 In this patch I add additional unit tests and better examples and complete documentation.
2017-03-13(#FM-6068) allow file encoding to be specified (#726)Geoff Williams
* (#FM-6068) allow file encoding to be specified Add a new parameter `encoding` to allow non UTF-8 files to specify a file encoding. This prevents receiving the error message "invalid byte sequence in UTF-8" when special characters that are not UTF-8 encoded appear in the input stream, such as the copyright symbol. * (#FM-6068) allow file encoding to be specified Added docs and tests as requested
2017-03-08(FM-6086) - Unit tests for Resource TypesPaula McMaw
2017-01-24(MODULES-4098) Sync the rest of the filesHunter Haugen
2016-03-28[MODULES-2370] file_line.rb: Fix `line` attribute validationJohnson Earls
`file_line` type: During validation, do not require `line` attribute if: * `ensure` is `absent`, * `match` is not empty, * and `match_for_absence` is `true`. Also update `spec` tests to reflect this.
2015-08-04(MODULES-2316) Change file_type boolean parameter to symbolsDominic Cleal
Puppet's boolean parameter type is only available in Puppet 3.3 and higher, so change file_type's new "replace" parameter to a regular parameter with true and false as possible values. This matches the existing "multiple" parameter.
2015-07-30(MODULES-2024) Adding replace attribute to file_lineRaymond Maika
2014-12-16Remove line match validationHunter Haugen
The `match` attribute was validated to match `line`, except that in many cases (even the example given in the docs) a user would want to match a line entirely different from the new line. See comments on the original commit https://github.com/puppetlabs/puppetlabs-stdlib/commit/a06c0d8115892a74666676b50d4282df9850a119 and ask https://ask.puppetlabs.com/question/14366/file_line-resource-match-problems/ for further examples of confusion.
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/unit * 53 conversions from: obj.should to: expect(obj).to * 19 conversions from: == expected to: eq(expected) * 5 conversions from: lambda { }.should to: expect { }.to * 2 conversions from: be_true to: be_truthy For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-05-15Revert "Merge pull request #256 from stbenjam/2571-before"Ashley Penney
This reverts commit 8499ebdb7f892f2623295058649c67a5553d4732, reversing changes made to 08b00d9229961d7b3c3cba997bfb35c8d47e4c4b.
2014-05-14(PUP-2571) add 'before' functionality to file_lineStephen Benjamin
file_line supports adding lines after a match, but there are use cases when having "before" would be useful. For example, in Debian-based OS's, the last line of /etc/rc.local is "exit 0" it's an incredible pain to deal with that scenario today. This commit adds a 'before' parameter to the file_line type, and implements it for the ruby provider.
2014-05-07Add mode +x to spec .rb filesHunter Haugen
2014-05-07Add the missing shebangs and fix the wrong ones for rpmlint to stop ↵Andrea Veri
complaining loudly
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.
2013-02-06ammend .should raise_error to .to raise_errorstephen
2012-11-26(#14670) Fixup file_line autorequire specsJeff McCune
Without this patch applied the file_line autorequire examples are failing. This is a problem because the failures are false positives and should be passing given the implementation. This patch fixes the problem by changing the examples to directly test the existence of the relationship by finding it in the list of autorequire relationships.
2012-11-26(#14670) autorequire a file_line resource's pathPeter Meier
If we manage a file we edit with file_line, it should be autorequired by file_line. Without this patch applied the relationship is not automatically setup and the user is forced to manually manage the relationship.
2012-08-14Add support for a 'match' parameter to file_lineChris Price
This commit adds a new parameter called "match" to the file_line resource type, and support for this new parameter to the corresponding ruby provider. This parameter is optional; file_line should work just as before if you do not specify this parameter... so this change should be backwards-compatible. If you do specify the parameter, it is treated as a regular expression that should be used when looking through the file for a line. This allows you to do things like find a line that begins with a certain prefix (e.g., "foo=.*"), and *replace* the existing line with the line you specify in your "line" parameter. Without this capability, if you already had a line "foo=bar" in your file and your "line" parameter was set to "foo=baz", you'd end up with *both* lines in the final file. In many cases this is undesirable.
2012-05-10Make file_line default to ensure => presentJeff McCune
The examples in the file_line resource documentation state the following resource should work: file_line { 'sudo_rule': path => '/etc/sudoers', line => '%sudo ALL=(ALL) ALL', } Without this patch the example does not work because ensure is not set to present. This patch fixes the problem by setting the default value of ensure to present.
2012-05-10Memoize file_line spec instance variablesJeff McCune
This just changes the instance variables to a memoized let block and gets ride of the before :each block. The patch has no change in behavior.
2011-08-04(#8792) Rename whole_line type to file_lineJeff McCune
Without this patch the resource whole_line would be included in the stable stdlib module shipping in PE 1.2. Ideally the name will be stable and unchanging in the future. There was quite a bit of concern over whole_line being an unwise name. file_line appears to be the most suitable name and least likely to need another rename in the future.