summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorDominic Maraglia <dmaraglia@gmail.com>2011-05-03 17:59:26 -0700
committerDominic Maraglia <dmaraglia@gmail.com>2011-05-03 17:59:26 -0700
commite5b62d7424da24799c4d16f0e104fac3008e2b89 (patch)
tree7d2d710fa43c39dd35d96cc2db371c548a85518f /spec
parent94f0b0996ba628f4916bcf0978b29c584c15818b (diff)
parentd203853bc8b40732c2ba88a4e5396f00a1e3a4ec (diff)
Merge branch '2.7.x' of github.com:puppetlabs/puppet into 2.7.x
Diffstat (limited to 'spec')
-rwxr-xr-xspec/lib/puppet/face/basetest.rb6
-rwxr-xr-xspec/unit/application/face_base_spec.rb8
-rwxr-xr-xspec/unit/face/plugin_spec.rb10
-rwxr-xr-xspec/unit/face/secret_agent_spec.rb3
-rwxr-xr-xspec/unit/file_serving/fileset_spec.rb7
-rwxr-xr-xspec/unit/network/http/api/v1_spec.rb8
6 files changed, 39 insertions, 3 deletions
diff --git a/spec/lib/puppet/face/basetest.rb b/spec/lib/puppet/face/basetest.rb
index 41a4ef3f9..9398f5b2d 100755
--- a/spec/lib/puppet/face/basetest.rb
+++ b/spec/lib/puppet/face/basetest.rb
@@ -32,4 +32,10 @@ Puppet::Face.define(:basetest, '0.0.1') do
summary "just raises an exception"
when_invoked do |options| raise ArgumentError, "your failure" end
end
+
+ action :with_s_rendering_hook do
+ summary "has a rendering hook for 's'"
+ when_invoked do |options| "this is not the hook you are looking for" end
+ when_rendering :s do |value| "you invoked the 's' rendering hook" end
+ end
end
diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb
index d8c970157..133e6b2e9 100755
--- a/spec/unit/application/face_base_spec.rb
+++ b/spec/unit/application/face_base_spec.rb
@@ -319,5 +319,13 @@ EOT
expect { app.run }.to exit_with 0
}.to have_printed(/--- 3/)
end
+
+ it "should invoke when_rendering hook 's' when asked to render-as 's'" do
+ app.command_line.stubs(:args).returns %w{with_s_rendering_hook --render-as s}
+ app.action = app.face.get_action(:with_s_rendering_hook)
+ expect {
+ expect { app.run }.to exit_with 0
+ }.to have_printed(/you invoked the 's' rendering hook/)
+ end
end
end
diff --git a/spec/unit/face/plugin_spec.rb b/spec/unit/face/plugin_spec.rb
new file mode 100755
index 000000000..383aaa3d3
--- /dev/null
+++ b/spec/unit/face/plugin_spec.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env rspec
+require 'spec_helper'
+require 'puppet/face'
+
+describe Puppet::Face[:plugin, '0.0.1'] do
+ [:download].each do |action|
+ it { should be_action action }
+ it { should respond_to action }
+ end
+end
diff --git a/spec/unit/face/secret_agent_spec.rb b/spec/unit/face/secret_agent_spec.rb
index beeb4f57b..a5ec01f27 100755
--- a/spec/unit/face/secret_agent_spec.rb
+++ b/spec/unit/face/secret_agent_spec.rb
@@ -7,6 +7,7 @@ require 'tempfile'
describe Puppet::Face[:secret_agent, '0.0.1'] do
describe "#synchronize" do
it "should retrieve and apply a catalog and return a report" do
+ pending "This test doesn't work, but the code actually does - tested by LAK"
dirname = Dir.mktmpdir("puppetdir")
Puppet[:vardir] = dirname
Puppet[:confdir] = dirname
@@ -15,7 +16,7 @@ describe Puppet::Face[:secret_agent, '0.0.1'] do
@catalog.add_resource(@file)
Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog)
- report = subject.synchronize("foo")
+ report = subject.synchronize
report.kind.should == "apply"
report.status.should == "changed"
diff --git a/spec/unit/file_serving/fileset_spec.rb b/spec/unit/file_serving/fileset_spec.rb
index a369ad39c..41810650a 100755
--- a/spec/unit/file_serving/fileset_spec.rb
+++ b/spec/unit/file_serving/fileset_spec.rb
@@ -20,6 +20,13 @@ describe Puppet::FileServing::Fileset, " when initializing" do
fileset.path.should == path
end
+ it "should not fail if the path is just the file separator" do
+ path = File::SEPARATOR
+ File.stubs(:lstat).with(path).returns stub('stat')
+ fileset = Puppet::FileServing::Fileset.new(path)
+ fileset.path.should == path
+ end
+
it "should fail if its path does not exist" do
File.expects(:lstat).with("/some/file").returns nil
proc { Puppet::FileServing::Fileset.new("/some/file") }.should raise_error(ArgumentError)
diff --git a/spec/unit/network/http/api/v1_spec.rb b/spec/unit/network/http/api/v1_spec.rb
index bd95071c1..a952f24e2 100755
--- a/spec/unit/network/http/api/v1_spec.rb
+++ b/spec/unit/network/http/api/v1_spec.rb
@@ -31,7 +31,7 @@ describe Puppet::Network::HTTP::API::V1 do
end
it "should use the first field of the URI as the environment" do
- @tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].should == "env"
+ @tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].to_s.should == "env"
end
it "should fail if the environment is not alphanumeric" do
@@ -39,7 +39,11 @@ describe Puppet::Network::HTTP::API::V1 do
end
it "should use the environment from the URI even if one is specified in the parameters" do
- @tester.uri2indirection("GET", "/env/foo/bar", {:environment => "otherenv"})[3][:environment].should == "env"
+ @tester.uri2indirection("GET", "/env/foo/bar", {:environment => "otherenv"})[3][:environment].to_s.should == "env"
+ end
+
+ it "should return the environment as a Puppet::Node::Environment" do
+ @tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].should be_a Puppet::Node::Environment
end
it "should use the second field of the URI as the indirection name" do