summaryrefslogtreecommitdiff
path: root/spec/unit/rails
AgeCommit message (Collapse)AuthorFilesLines
2014-04-07(PUP-2158) Default a missing manifest to no_manifestAndrew Parker1-1/+1
The tests were often creating environments that didn't need to have manifests. Since we didn't have a way of specifying that when they were written, we used '' to fill in the blank. This actually caused a large number of tests to try to find code to load in the PWD, which caused tests to break if a developer had parse errors in manifests being used for testing in the root directory of their puppet project. This changes the manifest to be optional and removes '' from those tests. The tests no longer fail if a bad manifest is in the PWD :D
2014-01-29(PUP-1118) Stop using Environment.newAndrew Parker1-1/+1
Instead of creating environments directly, we need to go through the configured environment loaders, otherwise environments can't come from other places.
2013-12-23(PUP-1133) Cleanup after Rails temp log filesEthan J. Brown1-0/+4
- With Rails code that establishes a logger that writes to a temp log file, the logger must be closed to release the file for cleanup on Windows, without having access denied messages
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune3-3/+3
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 McCune3-3/+3
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.
2012-02-28Don't stub the database in Puppet::Rails tests.Daniel Pittman3-28/+11
The tests for the Puppet::Rails::Host and other Rails interface class stubbed out parts of rails, in a way that confused things later on and ended up breaking unrelated tests ... but only when they were invoked in a very particular order. Thankfully, just using a scratch database is both cheap and easy here, and makes this all just work. So, do that instead. Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
2011-04-27Merge branch '2.6.next' into 2.7.nextMax Martin1-0/+8
* 2.6.next: (#3420) Nagios "name" attribute does not output correctly (#4487) When setting environment on a host, ensure it is a string. add test for ticket 7101 (#6487) Add some testing for OS X version support in DirectoryService provider (#6487) Directoryservice provider will fail in future OS releases
2011-04-26(#4487) When setting environment on a host, ensure it is a string.Josh Cooper1-0/+8
Before this change when environment strings were read out of the storeconfigs database, they were eventually converted up to Puppet::Node::Environment objects. When these objects are returned to the storeconfigs database, ActiveRecord dumps them as YAML, which begins the death-spiral of YAML. This change makes it so the host will always store the environment as a string, preventing the Puppet::Node::Environment object from being YAMLized, and stored as such in the database. This change was based on one by Richard Crowley. Paired-with: Jacob Helwig <jacob@puppetlabs.com> Reviewed-by: Jesse Wolfe <jesse@puppetlabs.com> Signed-off-by: Richard Crowley <r@rcrowley.org>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman3-6/+3
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 Pittman3-3/+3
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>
2011-01-06Merge branch '2.6.x' into nextNick Lewis3-9/+3
Conflicts: Rakefile lib/puppet/resource/type_collection.rb lib/puppet/simple_graph.rb lib/puppet/transaction.rb lib/puppet/transaction/report.rb lib/puppet/util/metric.rb spec/integration/indirector/report/rest_spec.rb spec/spec_specs/runnable_spec.rb spec/unit/configurer_spec.rb spec/unit/indirector_spec.rb spec/unit/transaction/change_spec.rb
2011-01-04(#5771) Upgrade rspec to version 2Matt Robinson3-9/+3
The biggest change is that we no longer need to monkey patch rspec to get confine behavior. Describe blocks can now be conditional like confine used to be. "describe" blocks with "shared => true" are now "shared_examples_for". Paired-With: Nick Lewis
2010-12-16maint: Fix tests that don't run on their ownMatt Robinson2-0/+2
From the spec directory I found all the specs that fail when run on their own. for TEST in `find . -name "*.rb" -type f`; do spec $TEST > /dev/null 2>&1 if [[ $? != 0 ]]; then echo $TEST fi done All of them were cases of missing requires. Paired-with: Nick Lewis <nick@puppetlabs.com>
2010-12-06maint: Use expand_path when requiring spec_helper or puppettestMatt Robinson3-3/+3
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-11-22maint: Fix tests that don't run on their ownMatt Robinson2-0/+2
From the spec directory I found all the specs that fail when run on their own. for TEST in `find . -name "*.rb" -type f`; do spec $TEST > /dev/null 2>&1 if [[ $? != 0 ]]; then echo $TEST fi done All of them were cases of missing requires. Paired-with: Nick Lewis <nick@puppetlabs.com>
2010-08-03[#4397]+[#4344] Move type-name resolution out of Puppet::Resource into the ↵Jesse Wolfe1-1/+1
AST resources. Move type-name resolution out of Puppet::Resource into the AST resources. Move find_resource_type out of Puppet::Resource into Scope Thus, never pass unqualified type names to Puppet::Resource objects. Thus, Puppet::Resource objects don't need the namespace property, and Puppet::Resource objects never consult the harddrive to look for .pp files that might contain their type definitions, Thus, performance is improved. Also removes the temporary fix for #4257 that caused #4397 (The code was too eager to look for a class in the topscope) Paired-With: Paul Berry <paul@puppetlabs.com> Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
2010-07-18[#4247] storeconfigs was calling Puppet::Parser::Resource.new with the wrong ↵Jesse Wolfe1-0/+16
arguments When the interface to Puppet::Resource changed, its subclass Puppet::Parser::Resource was also affected. One case of initializing those objects did not get updated when the code changed, causing storeconfigs to break. Also, this patch adds a error message that would have made it easier to catch this problem (as puppet could consume all memory and die trying to print the old error message)
2010-07-09Code smell: Two space indentationMarkus Roberts3-217/+217
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 Roberts3-0/+0
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 Roberts3-0/+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-25maint: Fixing test to reflect that host environment assignment now takes an ↵Matt Robinson1-1/+1
object instead of a string
2010-06-23[#3994] rename the specs to have _spec.rb at the endMarkus Roberts3-0/+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-02-17Removing Resource::Reference classesLuke Kanies1-1/+1
This commit is hopefully less messy than it first appears, but it's certainly cross-cutting. The reason for all of this is that we previously only looked up builtin resource types from outside the parser, but now that the defined resource types are available globally via environments, we can push that lookup code to Resource. Once we do that, however, we have to have environment and namespace information in every resource. Here I remove the Resource::Reference classes (except the AST class), and use Resource instances instead. I did this because the shared code between the two classes got incredibly complicated, such that they should have had a hierarchical relationship disallowed by their constants. This complexity convinced me just to get rid of References entirely. I also make Puppet::Parser::Resource a subclass of Puppet::Resource. There are still broken tests in test/, but this was a big enough commit I wanted to get it in. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
2009-12-23Fixing #2964 updated resources cannot be collected until they are exported twiceMarkus Roberts1-0/+20
This logic had a bug where it would not insert data if it had just been deleted. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
2009-07-18Feature #2378 - Implement "thin_storeconfigs"Brice Figureau1-0/+72
Thin storeconfigs is a limited version of storeconfigs that is more performant and still allows the exported/collected resources system wich is the primary use of storeconfigs. It works by storing to the database only the exported resources, tags and host facts. Since usually those exported resources are less than the number of total resources for a node, it is expected to be faster than regular storeconfigs (especially for the first run). Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
2009-06-03Always providing a value for 'exported' on Rails resourcesLuke Kanies1-0/+45
We often didn't set a value, unless it was true, which meant that if it had previously been true but was now false, we didn't fix it. We also were not always saving modified resources, which in some cases resulted in work not getting saved. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-04-24Fixing #2187 - Puppet::Resource is expected by Rails supportLuke Kanies2-0/+91
We previously used and expected Puppet::Parser::Resource instances, but 0.25 converts them all to Puppet::Resource instances before they're passed out of the compiler, so the Rails integration had to be changed to expect that. There's still some muddling, because the rails resources only generate parser resources, but that works for now because that's what we expect when collecting resources. Signed-off-by: Luke Kanies <luke@madstop.com>
2009-04-22Adding ActiveRecord terminus classes for Node and Facts.Luke Kanies1-0/+91
This is most of the way to replacing standard StoreConfigs integration with the Indirector. We still need to convert the Catalog and then change all of the integraiton points (which is mostly the 'store' call in the Compiler). Signed-off-by: Luke Kanies <luke@madstop.com>