summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-03-18 18:16:03 -0500
committerLuke Kanies <luke@madstop.com>2008-03-18 18:16:03 -0500
commita40e9b7dc58eef2e965e81f6c7be2dc7c14910d9 (patch)
tree133ce47fcf4de7107fd8a351d3bc3eaed9daf66f
parent7d35ae8fed989ef3edb8a304f625786a04ee5faa (diff)
Fixing some tests that only failed under certain
circumstances (mostly, when loaded with other files, or when loaded from rake or autotest rather than separately).
-rwxr-xr-xspec/unit/parser/resource.rb4
-rwxr-xr-xspec/unit/ral/type/file.rb11
-rwxr-xr-xtest/lib/puppettest.rb7
-rwxr-xr-xtest/ral/providers/cron/crontab.rb1
-rwxr-xr-xtest/ral/providers/sshkey/parsed.rb1
5 files changed, 14 insertions, 10 deletions
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 1948a3c07..776e9c742 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -257,9 +257,7 @@ describe Puppet::Parser::Resource do
it "should fail when the override was not created by a parent class" do
@override.source = "source2"
@override.source.expects(:child_of?).with("source1").returns(false)
- assert_raise(Puppet::ParseError, "Allowed unrelated resources to override") do
- @resource.merge(@override)
- end
+ lambda { @resource.merge(@override) }.should raise_error(Puppet::ParseError)
end
it "should succeed when the override was created in the current scope" do
diff --git a/spec/unit/ral/type/file.rb b/spec/unit/ral/type/file.rb
index 1ef924569..e1a597434 100755
--- a/spec/unit/ral/type/file.rb
+++ b/spec/unit/ral/type/file.rb
@@ -57,9 +57,10 @@ describe Puppet::Type.type(:file) do
describe "when managing links" do
require 'puppettest/support/assertions'
include PuppetTest
+ require 'tempfile'
before do
- @basedir = tempfile()
+ @basedir = tempfile
Dir.mkdir(@basedir)
@file = File.join(@basedir, "file")
@link = File.join(@basedir, "link")
@@ -71,21 +72,23 @@ describe Puppet::Type.type(:file) do
:path => @link,
:mode => "755"
)
+ @catalog = Puppet::Node::Catalog.new
+ @catalog.add_resource @resource
end
after do
- teardown
+ remove_tmp_files
end
it "should default to managing the link" do
- assert_events([], @resource)
+ @catalog.apply
# I convert them to strings so they display correctly if there's an error.
("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0644
end
it "should be able to follow links" do
@resource[:links] = :follow
- assert_events([:file_changed], @resource)
+ @catalog.apply
("%o" % (File.stat(@file).mode & 007777)).should == "%o" % 0755
end
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index e276bdf0f..63f8121b5 100755
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -43,6 +43,10 @@ class Class
end
module PuppetTest
+ # These need to be here for when rspec tests use these
+ # support methods.
+ @@tmpfiles = []
+
# Munge cli arguments, so we can enable debugging if we want
# and so we can run just specific methods.
def self.munge_argv
@@ -189,7 +193,7 @@ module PuppetTest
Dir.mkdir(@configpath)
end
- @@tmpfiles = [@configpath, tmpdir()]
+ @@tmpfiles << @configpath << tmpdir()
@@tmppids = []
@@cleaners = []
@@ -293,6 +297,7 @@ module PuppetTest
}
@@tmppids.clear
+
Puppet::Type.allclear
Puppet::Util::Storage.clear
Puppet.clear
diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb
index 1ff1e34ef..53bd76c50 100755
--- a/test/ral/providers/cron/crontab.rb
+++ b/test/ral/providers/cron/crontab.rb
@@ -5,7 +5,6 @@ require File.dirname(__FILE__) + '/../../../lib/puppettest'
require 'puppettest'
require 'mocha'
require 'puppettest/fileparsing'
-require 'puppet/type/cron'
class TestCronParsedProvider < Test::Unit::TestCase
include PuppetTest
diff --git a/test/ral/providers/sshkey/parsed.rb b/test/ral/providers/sshkey/parsed.rb
index b94b7a69a..4f18e6494 100755
--- a/test/ral/providers/sshkey/parsed.rb
+++ b/test/ral/providers/sshkey/parsed.rb
@@ -4,7 +4,6 @@ require File.dirname(__FILE__) + '/../../../lib/puppettest'
require 'puppettest'
require 'puppettest/fileparsing'
-require 'puppet/type/sshkey'
class TestParsedSSHKey < Test::Unit::TestCase
include PuppetTest