summaryrefslogtreecommitdiffstats
path: root/spec/unit/node_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '2.7.x'Nick Lewis2011-08-161-4/+1
|\ | | | | | | | | | | Conflicts: lib/puppet/provider/augeas/augeas.rb spec/unit/node_spec.rb
| * Do not leak indirector state from apply testsJacob Helwig2011-08-151-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the indirector state persists across tests, we were seeing order dependent test failures with tests that assumed the default indirector settings. Specifically, if the following tests were run in order, the first would cause failures in the second two: spec/unit/application/apply_spec.rb spec/unit/node_spec.rb spec/integration/node_spec.rb To protect against this state leakage, we now: - reset the Puppet::Node terminus before each test in spec/integration/node_spec.rb to ensure we are testing a clean environment. - reset the Puppet::Node, and Puppet::Node::Facts terminus, and cache class after each test in spec/unit/application/apply_spec.rb to prevent leakage into other tests. Since the cache class has the same state leakage problem as the terminus class, but does not have the same ability to lazily populate the default when set to nil, we remove the test. Testing the default for the cache class would require running the test before all other tests to ensure there is no state pollution.n
* | Rework Puppet::Util::Cacher to only expire using TTLsNick Lewis2011-07-211-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have removed every usage of cached_attr in which the attribute needs to be manually expired. Thus, the only meaningful behavior provided by Puppet::Util::Cacher is expiration based on TTLs. This commit reworks the cacher to only support that behavior. Rather than accepting an options hash, of which :ttl is the only available option, cached_attr now requires a second argument, which is the TTL. TTLs are now used to compute expirations, which are stored and used for expiring values. Previously, we stored a timestamp and used it and the TTL to determine whether the attribute was expired. This had the potentially undesirable side effect that the lifetime of a cached attribute could be extended after its insertion by modifying the TTL setting for the cache. Now, the lifetime of an attribute is determined when it is set, and is thereafter immutable, aside from deliberately re-setting the expiration for that particular attribute. Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
* | (#7080) Registering PSON document typesLuke Kanies2011-07-151-0/+8
| | | | | | | | | | | | | | | | | | We were originally using the actual constant for both Indirector Requests and Nodes, and this registers their document types as symbolic names. Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* | Switching to use of json matchersLuke Kanies2011-07-151-10/+10
| | | | | | | | | | | | | | | | | | This is only in the Node and Indirection::Request code. It makes the tests much simpler. Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
* | Adding json support to Puppet::NodeLuke Kanies2011-07-151-0/+63
|/ | | | | | Reviewed-by: Daniel Pittman <daniel@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com> Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Merge branch '2.6.x' into 2.7.xNick Lewis2011-06-081-0/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: acceptance/tests/ticket_5477_master_not_dectect_sitepp.rb lib/puppet/application/apply.rb lib/puppet/configurer.rb lib/puppet/configurer/fact_handler.rb spec/unit/application/apply_spec.rb spec/unit/configurer/fact_handler_spec.rb spec/unit/configurer_spec.rb
| * maint: Refactor specs in preparation for making node name more flexibleNick Lewis2011-06-021-0/+1
| | | | | | | | | | | | | | These tests were stubbing when it was unnecessary, so replace much of it with actual objects and files. Paired-With: Jacob Helwig <jacob@puppetlabs.com>
* | Revert "Adding json support to Puppet::Node"Max Martin2011-04-211-63/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit d3c94e62386ec03617015f6e6269b1de805954ea. The JSON patch series has caused problems with the inventory service, and further discussion is needed to decide how to serialize objects to PSON with regards to future compatibility. Conflicts (Manually resolved): spec/unit/node_spec.rb Paired-with: Matt Robinson <matt@puppetlabs.com>
* | Adding json-specific matchersLuke Kanies2011-04-141-10/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These make the JSON tests much easier to read and write. They're the first custom matchers that I can find, so they're breaking a bit of new ground, but the JSON tests were pretty hard to read and there was a lot of duplication, so it seemed worth it. Note that for some reason they're not working on Facts - it seems to get immediately turned into a full instance by the JSON parsing subsystem, and I've no idea why. Reviewed-by: Daniel Pittman <daniel@puppetlabs.com> Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* | Adding json support to Puppet::NodeLuke Kanies2011-04-141-0/+63
| | | | | | | | | | Reviewed-by: Daniel Pittman <daniel@puppetlabs.com> Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* | maint: clean up the spec test headers in bulk.Daniel Pittman2011-04-131-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.
* | maint: just require 'spec_helper', thanks rspec2Daniel Pittman2011-04-081-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>
* | maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson2010-12-061-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
* | Maint: Refactor tests to use <class>.indirection.<method>Paul Berry2010-11-291-9/+2
|/ | | | | | Replaced uses of the find, search, destroy, and expire methods on model classes with direct calls to the indirection objects. This change affects tests only.
* Code smell: Two space indentationMarkus Roberts2010-07-091-167/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [#3994-part 3] rename spec tests from *_spec_spec to *_spec.rbMarkus Roberts2010-06-281-0/+210
| | | | Part 2 re-did the change on the spec files, which it shouldn't have.
* [#3994-part 2] rename integration tests to *_spec.rbMarkus Roberts2010-06-281-210/+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
* [#3994] rename the specs to have _spec.rb at the endMarkus Roberts2010-06-231-0/+210
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