spec/unit/application/resource_spec.rb in puppet-2.6.12 vs spec/unit/application/resource_spec.rb in puppet-2.6.13
- old
+ new
@@ -228,6 +228,31 @@
@resource.main
end
end
end
+
+ describe "when handling file type" do
+ before :each do
+ Facter.stubs(:loadfacts)
+ @resource.preinit
+ end
+
+ it "should raise an exception if no file specified" do
+ @resource.command_line.stubs(:args).returns(['file'])
+
+ lambda { @resource.main }.should raise_error(RuntimeError, /Listing all file instances is not supported/)
+ end
+
+ it "should output a file resource when given a file path" do
+ res = Puppet::Type.type(:file).new(:path => "/etc").to_resource
+ Puppet::Resource.expects(:find).returns(res)
+
+ @resource.command_line.stubs(:args).returns(['file', '/etc'])
+ @resource.expects(:puts).with do |args|
+ args.should =~ /file \{ '\/etc'/m
+ end
+
+ @resource.main
+ end
+ end
end