From b6e34b7bc8af737927645e405032ab9694456097 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sat, 20 Dec 2008 15:29:58 +0100 Subject: Fix #1834 part1 - Fix tempfile failing tests Signed-off-by: Brice Figureau --- spec/integration/indirector/direct_file_server.rb | 3 ++- spec/integration/indirector/module_files.rb | 3 ++- spec/integration/type/file.rb | 3 ++- spec/integration/type/tidy.rb | 3 ++- spec/integration/util/settings.rb | 3 ++- spec/shared_behaviours/file_server_terminus.rb | 3 ++- spec/unit/type/file.rb | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/integration/indirector/direct_file_server.rb b/spec/integration/indirector/direct_file_server.rb index c379bcbb7..1f1ea0dcc 100755 --- a/spec/integration/indirector/direct_file_server.rb +++ b/spec/integration/indirector/direct_file_server.rb @@ -38,8 +38,9 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with FileServi @terminus = Puppet::Indirector::FileContent::File.new @path = Tempfile.new("direct_file_server_testing") + path = @path.path @path.close! - @path = @path.path + @path = path Dir.mkdir(@path) File.open(File.join(@path, "one"), "w") { |f| f.print "one content" } diff --git a/spec/integration/indirector/module_files.rb b/spec/integration/indirector/module_files.rb index a54588ec5..a474b7513 100755 --- a/spec/integration/indirector/module_files.rb +++ b/spec/integration/indirector/module_files.rb @@ -32,8 +32,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with FileServing::F @terminus = Puppet::Indirector::FileContent::Modules.new @path = Tempfile.new("module_file_testing") + path = @path.path @path.close! - @path = @path.path + @path = path Dir.mkdir(@path) Dir.mkdir(File.join(@path, "files")) diff --git a/spec/integration/type/file.rb b/spec/integration/type/file.rb index 8e31bbb24..87a478d54 100755 --- a/spec/integration/type/file.rb +++ b/spec/integration/type/file.rb @@ -5,8 +5,9 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe Puppet::Type.type(:file) do def tmpfile(name) source = Tempfile.new(name) + path = source.path source.close! - source.path + path end describe "when recursing" do diff --git a/spec/integration/type/tidy.rb b/spec/integration/type/tidy.rb index 5916d88e5..50ec3d7a6 100755 --- a/spec/integration/type/tidy.rb +++ b/spec/integration/type/tidy.rb @@ -5,8 +5,9 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe Puppet::Type.type(:tidy) do def tmpfile(name) source = Tempfile.new(name) + path = source.path source.close! - source.path + path end # Testing #355. diff --git a/spec/integration/util/settings.rb b/spec/integration/util/settings.rb index a78046462..d2fe86892 100755 --- a/spec/integration/util/settings.rb +++ b/spec/integration/util/settings.rb @@ -5,8 +5,9 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe Puppet::Util::Settings do def tmpfile(name) source = Tempfile.new(name) + path = source.path source.close! - source.path + path end it "should be able to make needed directories" do diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb index 13561f09c..1db6cfa0e 100644 --- a/spec/shared_behaviours/file_server_terminus.rb +++ b/spec/shared_behaviours/file_server_terminus.rb @@ -12,8 +12,9 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do FileTest.stubs(:exists?).with(Puppet[:fileserverconfig]).returns(true) @path = Tempfile.new("file_server_testing") + path = @path.path @path.close! - @path = @path.path + @path = path Dir.mkdir(@path) File.open(File.join(@path, "myfile"), "w") { |f| f.print "my content" } diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index 631284e3b..1bd049b5f 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -5,8 +5,9 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe Puppet::Type.type(:file) do before do @path = Tempfile.new("puppetspec") + pathname = @path.path @path.close!() - @path = @path.path + @path = pathname @file = Puppet::Type::File.new(:name => @path) @catalog = mock 'catalog' -- cgit From 3b8a77dfd97774c21156efb1553f3a5a0372c7fa Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sat, 20 Dec 2008 15:30:22 +0100 Subject: Fix #1834 part2 - Fix tests when no rails Signed-off-by: Brice Figureau --- spec/unit/parser/collector.rb | 4 ++-- spec/unit/parser/compiler.rb | 1 + spec/unit/rails.rb | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb index ede583b96..edd74e25f 100755 --- a/spec/unit/parser/collector.rb +++ b/spec/unit/parser/collector.rb @@ -194,7 +194,7 @@ describe Puppet::Parser::Collector, "when collecting virtual resources" do end describe Puppet::Parser::Collector, "when collecting exported resources" do - confine Puppet.features.rails? => "Cannot test Rails integration without ActiveRecord" + confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails? before do @scope = stub 'scope', :host => "myhost", :debug => nil @@ -364,7 +364,7 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do end describe Puppet::Parser::Collector, "when building its ActiveRecord query for collecting exported resources" do - confine Puppet.features.rails? => "Cannot test Rails integration without ActiveRecord" + confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails? before do @scope = stub 'scope', :host => "myhost", :debug => nil diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index 203105289..f36b6fd4f 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -478,6 +478,7 @@ describe Puppet::Parser::Compiler do end describe Puppet::Parser::Compiler, "when storing compiled resources" do + confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails? it "should store the resources" do Puppet.features.expects(:rails?).returns(true) diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb index 533236772..f0ba2b942 100755 --- a/spec/unit/rails.rb +++ b/spec/unit/rails.rb @@ -66,7 +66,7 @@ describe Puppet::Rails, "when initializing any connection" do end describe Puppet::Rails, "when initializing a sqlite3 connection" do - confine Puppet.features.rails? => "Cannot test without ActiveRecord" + confine "Cannot test without ActiveRecord" => Puppet.features.rails? it "should provide the adapter, log_level, and dbfile arguments" do Puppet.settings.expects(:value).with(:dbadapter).returns("sqlite3") @@ -82,7 +82,7 @@ describe Puppet::Rails, "when initializing a sqlite3 connection" do end describe Puppet::Rails, "when initializing a mysql or postgresql connection" do - confine Puppet.features.rails? => "Cannot test without ActiveRecord" + confine "Cannot test without ActiveRecord" => Puppet.features.rails? it "should provide the adapter, log_level, and host, username, password, and database arguments" do Puppet.settings.stubs(:value).with(:dbadapter).returns("mysql") -- cgit