summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2009-12-21 09:12:24 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-12-22 10:53:57 +1100
commit5e5c8b5414a69d79830b79392f0addce245c6911 (patch)
tree3feeeaa2380f9486556341fb558a5c566f85ab3a
parent0cb5e7d226934e74f8b53dc1f6425b47f536afab (diff)
downloadpuppet-5e5c8b5414a69d79830b79392f0addce245c6911.tar.gz
puppet-5e5c8b5414a69d79830b79392f0addce245c6911.tar.xz
puppet-5e5c8b5414a69d79830b79392f0addce245c6911.zip
Fixing tests
Signed-off-by: Markus Roberts <Markus@reality.com>
-rwxr-xr-xspec/unit/application/puppet.rb41
1 files changed, 11 insertions, 30 deletions
diff --git a/spec/unit/application/puppet.rb b/spec/unit/application/puppet.rb
index f4d606535..7703bac08 100755
--- a/spec/unit/application/puppet.rb
+++ b/spec/unit/application/puppet.rb
@@ -332,70 +332,51 @@ describe "Puppet" do
end
describe "the 'apply' command" do
- confine "PSON library is missing; cannot test applying catalogs" => Puppet.features.pson?
-
- before do
- #Puppet::Resource::Catalog.stubs(:pson_create).returns Puppet::Resource::Catalog.new
- PSON.stubs(:parse).returns Puppet::Resource::Catalog.new
- end
-
it "should read the catalog in from disk if a file name is provided" do
@puppet.options[:catalog] = "/my/catalog.pson"
-
File.expects(:read).with("/my/catalog.pson").returns "something"
-
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'something').returns Puppet::Resource::Catalog.new
@puppet.apply
end
it "should read the catalog in from stdin if '-' is provided" do
@puppet.options[:catalog] = "-"
-
$stdin.expects(:read).returns "something"
-
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'something').returns Puppet::Resource::Catalog.new
@puppet.apply
end
- it "should deserialize the catalog from pson" do
+ it "should deserialize the catalog from the default format" do
@puppet.options[:catalog] = "/my/catalog.pson"
-
- File.expects(:read).returns "something"
- PSON.expects(:parse).with("something").returns Puppet::Resource::Catalog.new
-
+ File.stubs(:read).with("/my/catalog.pson").returns "something"
+ Puppet::Resource::Catalog.stubs(:default_format).returns :rot13_piglatin
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:rot13_piglatin,'something').returns Puppet::Resource::Catalog.new
@puppet.apply
end
it "should fail helpfully if deserializing fails" do
@puppet.options[:catalog] = "/my/catalog.pson"
-
- File.expects(:read).returns "something"
- PSON.expects(:parse).raises ArgumentError
-
+ File.stubs(:read).with("/my/catalog.pson").returns "something syntacically invalid"
lambda { @puppet.apply }.should raise_error(Puppet::Error)
end
it "should convert plain data structures into a catalog if deserialization does not do so" do
@puppet.options[:catalog] = "/my/catalog.pson"
-
- File.expects(:read).returns "something"
- PSON.expects(:parse).with("something").returns({:foo => "bar"})
+ File.stubs(:read).with("/my/catalog.pson").returns "something"
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,"something").returns({:foo => "bar"})
Puppet::Resource::Catalog.expects(:pson_create).with({:foo => "bar"}).returns(Puppet::Resource::Catalog.new)
-
@puppet.apply
end
it "should convert the catalog to a RAL catalog and use a Configurer instance to apply it" do
@puppet.options[:catalog] = "/my/catalog.pson"
-
- File.expects(:read).returns "something"
-
+ File.stubs(:read).with("/my/catalog.pson").returns "something"
catalog = Puppet::Resource::Catalog.new
- PSON.expects(:parse).returns catalog
-
+ Puppet::Resource::Catalog.stubs(:convert_from).with(:pson,'something').returns catalog
catalog.expects(:to_ral).returns "mycatalog"
configurer = stub 'configurer'
Puppet::Configurer.expects(:new).returns configurer
-
configurer.expects(:run).with(:catalog => "mycatalog")
@puppet.apply