summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-07-22 13:30:05 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-07-22 13:30:05 -0700
commitfeec7b3df713569f76b93ae8cef882e9ddc1bf35 (patch)
tree89d10d48744e76da63a083de85a86d5b867565ca /spec/unit
parentf309e1e45c456cc1d53469863f59cbad0df37241 (diff)
parent532c4f37e4f8289cf4a9871ebc0cb5086c2ba26a (diff)
downloadpuppet-feec7b3df713569f76b93ae8cef882e9ddc1bf35.tar.gz
puppet-feec7b3df713569f76b93ae8cef882e9ddc1bf35.tar.xz
puppet-feec7b3df713569f76b93ae8cef882e9ddc1bf35.zip
Merge branch 'feature/2.7.x/7184-better-action-loading' into 2.7.x
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/application/face_base_spec.rb1
-rwxr-xr-xspec/unit/interface/face_collection_spec.rb42
-rwxr-xr-xspec/unit/interface_spec.rb9
3 files changed, 44 insertions, 8 deletions
diff --git a/spec/unit/application/face_base_spec.rb b/spec/unit/application/face_base_spec.rb
index 0a4a86be6..bebc26210 100755
--- a/spec/unit/application/face_base_spec.rb
+++ b/spec/unit/application/face_base_spec.rb
@@ -55,6 +55,7 @@ describe Puppet::Application::FaceBase do
it "should stop if the first thing found is not an action" do
app.command_line.stubs(:args).returns %w{banana count_args}
expect { app.run }.to exit_with 1
+ @logs.first.should_not be_nil
@logs.first.message.should =~ /has no 'banana' action/
end
diff --git a/spec/unit/interface/face_collection_spec.rb b/spec/unit/interface/face_collection_spec.rb
index 98887a778..514a624b1 100755
--- a/spec/unit/interface/face_collection_spec.rb
+++ b/spec/unit/interface/face_collection_spec.rb
@@ -35,7 +35,8 @@ describe Puppet::Interface::FaceCollection do
end
it "should attempt to load the face if it isn't found" do
- subject.expects(:require).with('puppet/face/bar')
+ subject.expects(:require).once.with('puppet/face/bar')
+ subject.expects(:require).once.with('puppet/face/0.0.1/bar')
subject["bar", '0.0.1']
end
@@ -64,7 +65,8 @@ describe Puppet::Interface::FaceCollection do
it "should return false if the face file itself is missing" do
subject.stubs(:require).
- raises(LoadError, 'no such file to load -- puppet/face/bar')
+ raises(LoadError, 'no such file to load -- puppet/face/bar').then.
+ raises(LoadError, 'no such file to load -- puppet/face/0.0.1/bar')
subject["bar", '0.0.1'].should be_false
end
@@ -97,6 +99,42 @@ describe Puppet::Interface::FaceCollection do
end
end
+ describe "::get_action_for_face" do
+ it "should return an action on the current face" do
+ Puppet::Face::FaceCollection.get_action_for_face(:huzzah, :bar, :current).
+ should be_an_instance_of Puppet::Interface::Action
+ end
+
+ it "should return an action on an older version of a face" do
+ action = Puppet::Face::FaceCollection.
+ get_action_for_face(:huzzah, :obsolete, :current)
+
+ action.should be_an_instance_of Puppet::Interface::Action
+ action.face.version.should == SemVer.new('1.0.0')
+ end
+
+ it "should load the full older version of a face" do
+ action = Puppet::Face::FaceCollection.
+ get_action_for_face(:huzzah, :obsolete, :current)
+
+ action.face.version.should == SemVer.new('1.0.0')
+ action.face.should be_action :obsolete_in_core
+ end
+
+ it "should not add obsolete actions to the current version" do
+ action = Puppet::Face::FaceCollection.
+ get_action_for_face(:huzzah, :obsolete, :current)
+
+ action.face.version.should == SemVer.new('1.0.0')
+ action.face.should be_action :obsolete_in_core
+
+ current = Puppet::Face[:huzzah, :current]
+ current.version.should == SemVer.new('2.0.1')
+ current.should_not be_action :obsolete_in_core
+ current.should_not be_action :obsolete
+ end
+ end
+
describe "::register" do
it "should store the face by name" do
face = Puppet::Face.new(:my_face, '0.0.1')
diff --git a/spec/unit/interface_spec.rb b/spec/unit/interface_spec.rb
index 4cb1f8743..4ff71ac3d 100755
--- a/spec/unit/interface_spec.rb
+++ b/spec/unit/interface_spec.rb
@@ -126,14 +126,11 @@ describe Puppet::Interface do
end
it "should try to require faces that are not known" do
- pending "mocking require causes random stack overflow"
- subject::FaceCollection.expects(:require).with "puppet/face/foo"
- subject[:foo, '0.0.1']
+ subject::FaceCollection.expects(:load_face).with(:foo, :current)
+ subject::FaceCollection.expects(:load_face).with(:foo, '0.0.1')
+ expect { subject[:foo, '0.0.1'] }.to raise_error Puppet::Error
end
- it "should be able to load all actions in all search paths"
-
-
it_should_behave_like "things that declare options" do
def add_options_to(&block)
subject.new(:with_options, '0.0.1', &block)