summaryrefslogtreecommitdiff
path: root/spec/unit/provider/parsedfile_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-06-11(PUP-1177) update ParsedFile provider unit testsFelix Frank1-1/+1
The constructor for the :flat filetype accepts a second argument now. This second argument must be taken into account when stubbing specific invocations.
2013-09-13(#19994) Ensure that failed ParsedFile operations are marked flushedPatrick Carlisle1-2/+40
Since ParsedFile maintains a global queue of records to be flushed and attempts to flush all outstanding operations each time a resource is flushed, any failed operations would be retried for each resource. This lead to unrelated resources failing.
2013-09-13(maint) Don't use subject in parsedfile specPatrick Carlisle1-47/+48
2013-07-09(Maint) Don't prefetch from /tmp/testJosh Cooper1-2/+3
Previously, the parsed file provider was prefetching and reading from /tmp/test, which failed if you happened to have a directory /tmp/test. This commit updates the test to use a temporary and empty file from it prefetches. Paired-with: Rob Reynolds <rob@puppetlabs.com> Paired-with: Kylo Ginsberg <kylo@puppetlabs.com>
2013-04-09(#2251) add specs around resource_for_recordAdrien Thebo1-0/+17
2013-03-15(#5752) Raise specific error in file typeAdrien Thebo1-11/+11
The current behavior of read errors in file types is to raise a generic error, which is difficult to rescue without rescuing everything. This commit adds a new exception subclass that can be explicitly rescued without rescuing every other error.
2013-03-13(#5752) Handle read errors in parsedfile providerStefan Schulte1-0/+21
The parsedfile provider can handle multiple targets (multiple files, multiple crontabs, etc) but the provider does not handle the case when retrieving a target during prefetch fails. When the provider does only handle one target this doesn't really matter because a possible error is caught at a higher level (inside Puppet::Transaction). But if the provider handles multiple targets, one error will cause the whole prefetching method to fail and all targets are treated as empty. One example of the issue is described in #5752: Multiple crontabs are manages with crontab resources and one cronresource describes a cronentry of an absent user. Because prefetching the crontab of the absent user fails, the crontab of *all* users are purged and every crontab entry which is not managed by puppet is lost. The change now handles the error inside the parsedfile provider itself, so only the target that is causing troubles is treated as empty.
2013-02-26(maint) convert parsedfile helpers to let blocksAdrien Thebo1-13/+10
This commit replaces the use of instance variables with `let` blocks in the parsedfile provider specs.
2013-02-26(maint) Refactor parsedfile specs to remove instance varsAdrien Thebo1-28/+32
The current test coverage for the ParsedFile provider uses an instance variable referencing the class. This commit removes the instance variable use and replaces them by setting `subject` to an anonymous subclass of ParsedFile.
2013-02-23Refactor the ParsedFile provider unit testFelix Frank1-8/+12
The initial implementation of the unit tests for a simple provider inheriting ParsedFile was imperfect and full of repitition. The restructuring makes the code reflect the semantics a lot better. Based on suggestions from Adrien Thebo.
2013-02-15(#593) parsedfile: add support for native file headersFelix Frank1-0/+51
Some managed configurations (notably the vixie cron crontabs) are automatically prefixed with headers not unlike those generated by puppet providers themselves. This can lead to "mutual 1up" situations in which puppet and the third party software will insert header upon header in their respective output. This change introduces the a "native header" for a parsed file. Providers can define a regex object that will be used to identify the part of a parsed file that comprises such a vendor header. When writing the content back to disk, puppet will try and insert its own header underneath the vendor's headers. Additionally, providers can override a "drop native headers" field in order to have puppet skip the vendor header alltogether when writing file contents. This allows "smart" software like vixie cron to manage its header on its own. The unit tests are based on example code kindly provided by Jeff McCune.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-2/+1
We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-1/+1
rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson1-1/+1
Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe
2010-07-09Code smell: Two space indentationMarkus Roberts1-69/+69
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
2010-06-28[#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts1-0/+95
Part 2 re-did the change on the spec files, which it shouldn't have.
2010-06-28[#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts1-95/+0
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700
2010-06-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts1-0/+95
Some spec files like active_record.rb had names that would confuse the load path and get loaded instead of the intended implentation when the spec was run from the same directory as the file. Author: Matt Robinson <matt@puppetlabs.com> Date: Fri Jun 11 15:29:33 2010 -0700