summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-04-07 15:44:28 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-07 15:52:05 -0700
commit87ed3188e65d3f5f9c2c32a409b271d1b39684b9 (patch)
tree36f3583ee364ba1d68467a2b614a8dfcf9ed43ae /spec
parent8d144d0bf5116c5f04522f2b4cd75699f6480f8e (diff)
(#7012) Split plumbing into Puppet::Interface
This splits out the plumbing into the Puppet::Interface namespace, and uses Puppet::Faces for all the public-facing code. The fault line is "what you care about if you are using or writing a face", which is public, against "what you care about to enable either of those two", which is the plumbing.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/faces/catalog_spec.rb5
-rwxr-xr-xspec/unit/faces/certificate_request_spec.rb5
-rwxr-xr-xspec/unit/faces/certificate_revocation_list_spec.rb5
-rwxr-xr-xspec/unit/faces/file_spec.rb5
-rwxr-xr-xspec/unit/faces/key_spec.rb5
-rw-r--r--spec/unit/faces/option_builder_spec.rb29
-rwxr-xr-xspec/unit/faces/report_spec.rb5
-rwxr-xr-xspec/unit/faces/resource_spec.rb5
-rwxr-xr-xspec/unit/faces/resource_type_spec.rb5
-rwxr-xr-xspec/unit/interface/action_builder_spec.rb (renamed from spec/unit/faces/action_builder_spec.rb)22
-rwxr-xr-xspec/unit/interface/action_manager_spec.rb (renamed from spec/unit/faces/action_manager_spec.rb)16
-rwxr-xr-xspec/unit/interface/action_spec.rb (renamed from spec/unit/faces/action_spec.rb)32
-rwxr-xr-xspec/unit/interface/face_collection_spec.rb (renamed from spec/unit/faces/face_collection_spec.rb)6
-rw-r--r--spec/unit/interface/option_builder_spec.rb29
-rw-r--r--spec/unit/interface/option_spec.rb (renamed from spec/unit/faces/option_spec.rb)30
-rwxr-xr-xspec/unit/interface_spec.rb (renamed from spec/unit/faces_spec.rb)55
16 files changed, 118 insertions, 141 deletions
diff --git a/spec/unit/faces/catalog_spec.rb b/spec/unit/faces/catalog_spec.rb
index 7621a864a..71972194a 100755
--- a/spec/unit/faces/catalog_spec.rb
+++ b/spec/unit/faces/catalog_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:catalog, '0.0.1'] do
+ it "should actually have some testing..."
end
diff --git a/spec/unit/faces/certificate_request_spec.rb b/spec/unit/faces/certificate_request_spec.rb
index 637ea8c38..1a71a8379 100755
--- a/spec/unit/faces/certificate_request_spec.rb
+++ b/spec/unit/faces/certificate_request_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:certificate_request, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/certificate_revocation_list_spec.rb b/spec/unit/faces/certificate_revocation_list_spec.rb
index e319b18e2..4f41edef6 100755
--- a/spec/unit/faces/certificate_revocation_list_spec.rb
+++ b/spec/unit/faces/certificate_revocation_list_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:certificate_revocation_list, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/file_spec.rb b/spec/unit/faces/file_spec.rb
index aafa88ce0..fcb52c67e 100755
--- a/spec/unit/faces/file_spec.rb
+++ b/spec/unit/faces/file_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:file, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/key_spec.rb b/spec/unit/faces/key_spec.rb
index 70d4a52c1..9b7a58706 100755
--- a/spec/unit/faces/key_spec.rb
+++ b/spec/unit/faces/key_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:key, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/option_builder_spec.rb b/spec/unit/faces/option_builder_spec.rb
deleted file mode 100644
index 9296ba7b6..000000000
--- a/spec/unit/faces/option_builder_spec.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-require 'puppet/faces/option_builder'
-
-describe Puppet::Faces::OptionBuilder do
- let :face do Puppet::Faces.new(:option_builder_testing, '0.0.1') end
-
- it "should be able to construct an option without a block" do
- Puppet::Faces::OptionBuilder.build(face, "--foo").
- should be_an_instance_of Puppet::Faces::Option
- end
-
- describe "when using the DSL block" do
- it "should work with an empty block" do
- option = Puppet::Faces::OptionBuilder.build(face, "--foo") do
- # This block deliberately left blank.
- end
-
- option.should be_an_instance_of Puppet::Faces::Option
- end
-
- it "should support documentation declarations" do
- text = "this is the description"
- option = Puppet::Faces::OptionBuilder.build(face, "--foo") do
- desc text
- end
- option.should be_an_instance_of Puppet::Faces::Option
- option.desc.should == text
- end
- end
-end
diff --git a/spec/unit/faces/report_spec.rb b/spec/unit/faces/report_spec.rb
index f7a67349c..30897d5e7 100755
--- a/spec/unit/faces/report_spec.rb
+++ b/spec/unit/faces/report_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:report, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/resource_spec.rb b/spec/unit/faces/resource_spec.rb
index 0b4b24882..e3f2e1c62 100755
--- a/spec/unit/faces/resource_spec.rb
+++ b/spec/unit/faces/resource_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:resource, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/resource_type_spec.rb b/spec/unit/faces/resource_type_spec.rb
index 157066f2d..fcbf07520 100755
--- a/spec/unit/faces/resource_type_spec.rb
+++ b/spec/unit/faces/resource_type_spec.rb
@@ -1,6 +1,3 @@
-#!/usr/bin/env ruby
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-
describe Puppet::Faces[:resource_type, '0.0.1'] do
+ it "should actually have some tests..."
end
diff --git a/spec/unit/faces/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb
index 5c8b98849..ae9cc83d4 100755
--- a/spec/unit/faces/action_builder_spec.rb
+++ b/spec/unit/interface/action_builder_spec.rb
@@ -1,20 +1,20 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/faces/action_builder'
+require 'puppet/interface/action_builder'
-describe Puppet::Faces::ActionBuilder do
+describe Puppet::Interface::ActionBuilder do
describe "::build" do
it "should build an action" do
- action = Puppet::Faces::ActionBuilder.build(nil, :foo) do
+ action = Puppet::Interface::ActionBuilder.build(nil, :foo) do
end
- action.should be_a(Puppet::Faces::Action)
+ action.should be_a(Puppet::Interface::Action)
action.name.should == :foo
end
it "should define a method on the face which invokes the action" do
- face = Puppet::Faces.new(:action_builder_test_faces, '0.0.1')
- action = Puppet::Faces::ActionBuilder.build(face, :foo) do
+ face = Puppet::Interface.new(:action_builder_test_interface, '0.0.1')
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
when_invoked do
"invoked the method"
end
@@ -24,30 +24,30 @@ describe Puppet::Faces::ActionBuilder do
end
it "should require a block" do
- expect { Puppet::Faces::ActionBuilder.build(nil, :foo) }.
+ expect { Puppet::Interface::ActionBuilder.build(nil, :foo) }.
should raise_error("Action :foo must specify a block")
end
describe "when handling options" do
- let :face do Puppet::Faces.new(:option_handling, '0.0.1') end
+ let :face do Puppet::Interface.new(:option_handling, '0.0.1') end
it "should have a #option DSL function" do
method = nil
- Puppet::Faces::ActionBuilder.build(face, :foo) do
+ Puppet::Interface::ActionBuilder.build(face, :foo) do
method = self.method(:option)
end
method.should be
end
it "should define an option without a block" do
- action = Puppet::Faces::ActionBuilder.build(face, :foo) do
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
option "--bar"
end
action.should be_option :bar
end
it "should accept an empty block" do
- action = Puppet::Faces::ActionBuilder.build(face, :foo) do
+ action = Puppet::Interface::ActionBuilder.build(face, :foo) do
option "--bar" do
# This space left deliberately blank.
end
diff --git a/spec/unit/faces/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb
index 61d1c1df5..50bea5f89 100755
--- a/spec/unit/faces/action_manager_spec.rb
+++ b/spec/unit/interface/action_manager_spec.rb
@@ -2,14 +2,14 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-# This is entirely an internal class for Faces, so we have to load it instead of our class.
-require 'puppet/faces'
+# This is entirely an internal class for Interface, so we have to load it instead of our class.
+require 'puppet/interface'
class ActionManagerTester
- include Puppet::Faces::ActionManager
+ include Puppet::Interface::ActionManager
end
-describe Puppet::Faces::ActionManager do
+describe Puppet::Interface::ActionManager do
subject { ActionManagerTester.new }
describe "when included in a class" do
@@ -73,7 +73,7 @@ describe Puppet::Faces::ActionManager do
end
describe "when used to extend a class" do
- subject { Class.new.extend(Puppet::Faces::ActionManager) }
+ subject { Class.new.extend(Puppet::Interface::ActionManager) }
it "should be able to define an action" do
subject.action(:foo) do
@@ -102,8 +102,8 @@ describe Puppet::Faces::ActionManager do
describe "when used both at the class and instance level" do
before do
@klass = Class.new do
- include Puppet::Faces::ActionManager
- extend Puppet::Faces::ActionManager
+ include Puppet::Interface::ActionManager
+ extend Puppet::Interface::ActionManager
end
@instance = @klass.new
end
@@ -216,7 +216,7 @@ describe Puppet::Faces::ActionManager do
describe "#get_action" do
let :parent_class do
- parent_class = Class.new(Puppet::Faces)
+ parent_class = Class.new(Puppet::Interface)
parent_class.action(:foo) {}
parent_class
end
diff --git a/spec/unit/faces/action_spec.rb b/spec/unit/interface/action_spec.rb
index c087744b1..4801a3cc8 100755
--- a/spec/unit/faces/action_spec.rb
+++ b/spec/unit/interface/action_spec.rb
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
-require 'puppet/faces/action'
+require 'puppet/interface/action'
-describe Puppet::Faces::Action do
+describe Puppet::Interface::Action do
describe "when validating the action name" do
[nil, '', 'foo bar', '-foobar'].each do |input|
it "should treat #{input.inspect} as an invalid name" do
- expect { Puppet::Faces::Action.new(nil, input) }.
+ expect { Puppet::Interface::Action.new(nil, input) }.
should raise_error(/is an invalid action name/)
end
end
@@ -15,7 +15,7 @@ describe Puppet::Faces::Action do
describe "when invoking" do
it "should be able to call other actions on the same object" do
- face = Puppet::Faces.new(:my_face, '0.0.1') do
+ face = Puppet::Interface.new(:my_face, '0.0.1') do
action(:foo) do
when_invoked { 25 }
end
@@ -33,7 +33,7 @@ describe Puppet::Faces::Action do
# baz is an instance action calling a class action
# qux is an instance action calling an instance action
it "should be able to call other actions on the same object when defined on a class" do
- class Puppet::Faces::MyFacesBaseClass < Puppet::Faces
+ class Puppet::Interface::MyInterfaceBaseClass < Puppet::Interface
action(:foo) do
when_invoked { 25 }
end
@@ -47,7 +47,7 @@ describe Puppet::Faces::Action do
end
end
- face = Puppet::Faces::MyFacesBaseClass.new(:my_inherited_face, '0.0.1') do
+ face = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_face, '0.0.1') do
action(:baz) do
when_invoked { "the value of foo in baz is '#{foo}'" }
end
@@ -65,7 +65,7 @@ describe Puppet::Faces::Action do
context "when calling the Ruby API" do
let :face do
- Puppet::Faces.new(:ruby_api, '1.0.0') do
+ Puppet::Interface.new(:ruby_api, '1.0.0') do
action :bar do
when_invoked do |options|
options
@@ -88,7 +88,7 @@ describe Puppet::Faces::Action do
describe "with action-level options" do
it "should support options with an empty block" do
- face = Puppet::Faces.new(:action_level_options, '0.0.1') do
+ face = Puppet::Interface.new(:action_level_options, '0.0.1') do
action :foo do
option "--bar" do
# this line left deliberately blank
@@ -101,7 +101,7 @@ describe Puppet::Faces::Action do
end
it "should return only action level options when there are no face options" do
- face = Puppet::Faces.new(:action_level_options, '0.0.1') do
+ face = Puppet::Interface.new(:action_level_options, '0.0.1') do
action :foo do option "--bar" end
end
@@ -110,7 +110,7 @@ describe Puppet::Faces::Action do
describe "with both face and action options" do
let :face do
- Puppet::Faces.new(:action_level_options, '0.0.1') do
+ Puppet::Interface.new(:action_level_options, '0.0.1') do
action :foo do option "--bar" end
action :baz do option "--bim" end
option "--quux"
@@ -122,7 +122,7 @@ describe Puppet::Faces::Action do
end
it "should fetch options that the face inherited" do
- parent = Class.new(Puppet::Faces)
+ parent = Class.new(Puppet::Interface)
parent.option "--foo"
child = parent.new(:inherited_options, '0.0.1') do
option "--bar"
@@ -133,18 +133,18 @@ describe Puppet::Faces::Action do
action.should be
[:baz, :bar, :foo].each do |name|
- action.get_option(name).should be_an_instance_of Puppet::Faces::Option
+ action.get_option(name).should be_an_instance_of Puppet::Interface::Option
end
end
it "should get an action option when asked" do
face.get_action(:foo).get_option(:bar).
- should be_an_instance_of Puppet::Faces::Option
+ should be_an_instance_of Puppet::Interface::Option
end
it "should get a face option when asked" do
face.get_action(:foo).get_option(:quux).
- should be_an_instance_of Puppet::Faces::Option
+ should be_an_instance_of Puppet::Interface::Option
end
it "should return options only for this action" do
@@ -154,7 +154,7 @@ describe Puppet::Faces::Action do
it_should_behave_like "things that declare options" do
def add_options_to(&block)
- face = Puppet::Faces.new(:with_options, '0.0.1') do
+ face = Puppet::Interface.new(:with_options, '0.0.1') do
action(:foo, &block)
end
face.get_action(:foo)
@@ -163,7 +163,7 @@ describe Puppet::Faces::Action do
it "should fail when a face option duplicates an action option" do
expect {
- Puppet::Faces.new(:action_level_options, '0.0.1') do
+ Puppet::Interface.new(:action_level_options, '0.0.1') do
option "--foo"
action :bar do option "--foo" end
end
diff --git a/spec/unit/faces/face_collection_spec.rb b/spec/unit/interface/face_collection_spec.rb
index 30147a548..de6d29cee 100755
--- a/spec/unit/faces/face_collection_spec.rb
+++ b/spec/unit/interface/face_collection_spec.rb
@@ -3,12 +3,12 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
require 'tmpdir'
-describe Puppet::Faces::FaceCollection do
+describe Puppet::Interface::FaceCollection do
# To avoid cross-pollution we have to save and restore both the hash
- # containing all the faces data, and the array used by require. Restoring
+ # containing all the interface data, and the array used by require. Restoring
# both means that we don't leak side-effects across the code. --daniel 2011-04-06
before :each do
- @original_faces = subject.instance_variable_get("@faces").dup
+ @original_faces = subject.instance_variable_get("@faces").dup
@original_required = $".dup
subject.instance_variable_get("@faces").clear
end
diff --git a/spec/unit/interface/option_builder_spec.rb b/spec/unit/interface/option_builder_spec.rb
new file mode 100644
index 000000000..fae48324e
--- /dev/null
+++ b/spec/unit/interface/option_builder_spec.rb
@@ -0,0 +1,29 @@
+require 'puppet/interface/option_builder'
+
+describe Puppet::Interface::OptionBuilder do
+ let :face do Puppet::Interface.new(:option_builder_testing, '0.0.1') end
+
+ it "should be able to construct an option without a block" do
+ Puppet::Interface::OptionBuilder.build(face, "--foo").
+ should be_an_instance_of Puppet::Interface::Option
+ end
+
+ describe "when using the DSL block" do
+ it "should work with an empty block" do
+ option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ # This block deliberately left blank.
+ end
+
+ option.should be_an_instance_of Puppet::Interface::Option
+ end
+
+ it "should support documentation declarations" do
+ text = "this is the description"
+ option = Puppet::Interface::OptionBuilder.build(face, "--foo") do
+ desc text
+ end
+ option.should be_an_instance_of Puppet::Interface::Option
+ option.desc.should == text
+ end
+ end
+end
diff --git a/spec/unit/faces/option_spec.rb b/spec/unit/interface/option_spec.rb
index a28fef087..3bcd121e2 100644
--- a/spec/unit/faces/option_spec.rb
+++ b/spec/unit/interface/option_spec.rb
@@ -1,14 +1,14 @@
-require 'puppet/faces/option'
+require 'puppet/interface/option'
-describe Puppet::Faces::Option do
- let :face do Puppet::Faces.new(:option_testing, '0.0.1') end
+describe Puppet::Interface::Option do
+ let :face do Puppet::Interface.new(:option_testing, '0.0.1') end
describe "#optparse_to_name" do
["", "=BAR", " BAR", "=bar", " bar"].each do |postfix|
{ "--foo" => :foo, "-f" => :f }.each do |base, expect|
input = base + postfix
it "should map #{input.inspect} to #{expect.inspect}" do
- option = Puppet::Faces::Option.new(face, input)
+ option = Puppet::Interface::Option.new(face, input)
option.name.should == expect
end
end
@@ -16,58 +16,58 @@ describe Puppet::Faces::Option do
[:foo, 12, nil, {}, []].each do |input|
it "should fail sensible when given #{input.inspect}" do
- expect { Puppet::Faces::Option.new(face, input) }.
+ expect { Puppet::Interface::Option.new(face, input) }.
should raise_error ArgumentError, /is not valid for an option argument/
end
end
["-foo", "-foo=BAR", "-foo BAR"].each do |input|
it "should fail with a single dash for long option #{input.inspect}" do
- expect { Puppet::Faces::Option.new(face, input) }.
+ expect { Puppet::Interface::Option.new(face, input) }.
should raise_error ArgumentError, /long options need two dashes \(--\)/
end
end
end
it "requires a face when created" do
- expect { Puppet::Faces::Option.new }.
+ expect { Puppet::Interface::Option.new }.
should raise_error ArgumentError, /wrong number of arguments/
end
it "also requires some declaration arguments when created" do
- expect { Puppet::Faces::Option.new(face) }.
+ expect { Puppet::Interface::Option.new(face) }.
should raise_error ArgumentError, /No option declarations found/
end
it "should infer the name from an optparse string" do
- option = Puppet::Faces::Option.new(face, "--foo")
+ option = Puppet::Interface::Option.new(face, "--foo")
option.name.should == :foo
end
it "should infer the name when multiple optparse string are given" do
- option = Puppet::Faces::Option.new(face, "--foo", "-f")
+ option = Puppet::Interface::Option.new(face, "--foo", "-f")
option.name.should == :foo
end
it "should prefer the first long option name over a short option name" do
- option = Puppet::Faces::Option.new(face, "-f", "--foo")
+ option = Puppet::Interface::Option.new(face, "-f", "--foo")
option.name.should == :foo
end
it "should create an instance when given a face and name" do
- Puppet::Faces::Option.new(face, "--foo").
- should be_instance_of Puppet::Faces::Option
+ Puppet::Interface::Option.new(face, "--foo").
+ should be_instance_of Puppet::Interface::Option
end
describe "#to_s" do
it "should transform a symbol into a string" do
- option = Puppet::Faces::Option.new(face, "--foo")
+ option = Puppet::Interface::Option.new(face, "--foo")
option.name.should == :foo
option.to_s.should == "foo"
end
it "should use - rather than _ to separate words in strings but not symbols" do
- option = Puppet::Faces::Option.new(face, "--foo-bar")
+ option = Puppet::Interface::Option.new(face, "--foo-bar")
option.name.should == :foo_bar
option.to_s.should == "foo-bar"
end
diff --git a/spec/unit/faces_spec.rb b/spec/unit/interface_spec.rb
index 586abd6b5..afcf95dcf 100755
--- a/spec/unit/faces_spec.rb
+++ b/spec/unit/interface_spec.rb
@@ -1,48 +1,49 @@
-#!/usr/bin/env ruby
+require 'puppet/faces'
+require 'puppet/interface'
-require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
+describe Puppet::Interface do
+ subject { Puppet::Interface }
-describe Puppet::Faces do
before :all do
- @faces = Puppet::Faces::FaceCollection.instance_variable_get("@faces").dup
+ @faces = Puppet::Interface::FaceCollection.instance_variable_get("@faces").dup
end
before :each do
- Puppet::Faces::FaceCollection.instance_variable_get("@faces").clear
+ Puppet::Interface::FaceCollection.instance_variable_get("@faces").clear
end
after :all do
- Puppet::Faces::FaceCollection.instance_variable_set("@faces", @faces)
+ Puppet::Interface::FaceCollection.instance_variable_set("@faces", @faces)
end
describe "#define" do
it "should register the face" do
- face = Puppet::Faces.define(:face_test_register, '0.0.1')
- face.should == Puppet::Faces[:face_test_register, '0.0.1']
+ face = subject.define(:face_test_register, '0.0.1')
+ face.should == subject[:face_test_register, '0.0.1']
end
it "should load actions" do
- Puppet::Faces.any_instance.expects(:load_actions)
- Puppet::Faces.define(:face_test_load_actions, '0.0.1')
+ subject.any_instance.expects(:load_actions)
+ subject.define(:face_test_load_actions, '0.0.1')
end
it "should require a version number" do
- expect { Puppet::Faces.define(:no_version) }.should raise_error ArgumentError
+ expect { subject.define(:no_version) }.should raise_error ArgumentError
end
end
describe "#initialize" do
it "should require a version number" do
- expect { Puppet::Faces.new(:no_version) }.should raise_error ArgumentError
+ expect { subject.new(:no_version) }.should raise_error ArgumentError
end
it "should require a valid version number" do
- expect { Puppet::Faces.new(:bad_version, 'Rasins') }.
+ expect { subject.new(:bad_version, 'Rasins') }.
should raise_error ArgumentError
end
it "should instance-eval any provided block" do
- face = Puppet::Faces.new(:face_test_block, '0.0.1') do
+ face = subject.new(:face_test_block, '0.0.1') do
action(:something) do
when_invoked { "foo" }
end
@@ -53,31 +54,31 @@ describe Puppet::Faces do
end
it "should have a name" do
- Puppet::Faces.new(:me, '0.0.1').name.should == :me
+ subject.new(:me, '0.0.1').name.should == :me
end
it "should stringify with its own name" do
- Puppet::Faces.new(:me, '0.0.1').to_s.should =~ /\bme\b/
+ subject.new(:me, '0.0.1').to_s.should =~ /\bme\b/
end
it "should allow overriding of the default format" do
- face = Puppet::Faces.new(:me, '0.0.1')
+ face = subject.new(:me, '0.0.1')
face.set_default_format :foo
face.default_format.should == :foo
end
it "should default to :pson for its format" do
- Puppet::Faces.new(:me, '0.0.1').default_format.should == :pson
+ subject.new(:me, '0.0.1').default_format.should == :pson
end
# Why?
it "should create a class-level autoloader" do
- Puppet::Faces.autoloader.should be_instance_of(Puppet::Util::Autoload)
+ subject.autoloader.should be_instance_of(Puppet::Util::Autoload)
end
it "should try to require faces that are not known" do
- Puppet::Faces::FaceCollection.expects(:require).with "puppet/faces/foo"
- Puppet::Faces[:foo, '0.0.1']
+ subject::FaceCollection.expects(:require).with "puppet/faces/foo"
+ subject[:foo, '0.0.1']
end
it "should be able to load all actions in all search paths"
@@ -85,13 +86,13 @@ describe Puppet::Faces do
it_should_behave_like "things that declare options" do
def add_options_to(&block)
- Puppet::Faces.new(:with_options, '0.0.1', &block)
+ subject.new(:with_options, '0.0.1', &block)
end
end
describe "with face-level options" do
it "should not return any action-level options" do
- face = Puppet::Faces.new(:with_options, '0.0.1') do
+ face = subject.new(:with_options, '0.0.1') do
option "--foo"
option "--bar"
action :baz do
@@ -103,7 +104,7 @@ describe Puppet::Faces do
it "should fail when a face option duplicates an action option" do
expect {
- Puppet::Faces.new(:action_level_options, '0.0.1') do
+ subject.new(:action_level_options, '0.0.1') do
action :bar do option "--foo" end
option "--foo"
end
@@ -111,7 +112,7 @@ describe Puppet::Faces do
end
it "should work when two actions have the same option" do
- face = Puppet::Faces.new(:with_options, '0.0.1') do
+ face = subject.new(:with_options, '0.0.1') do
action :foo do option "--quux" end
action :bar do option "--quux" end
end
@@ -123,7 +124,7 @@ describe Puppet::Faces do
describe "with inherited options" do
let :face do
- parent = Class.new(Puppet::Faces)
+ parent = Class.new(subject)
parent.option("--inherited")
face = parent.new(:example, '0.2.1')
face.option("--local")
@@ -138,7 +139,7 @@ describe Puppet::Faces do
describe "#get_option" do
it "should return an inherited option object" do
- face.get_option(:inherited).should be_an_instance_of Puppet::Faces::Option
+ face.get_option(:inherited).should be_an_instance_of subject::Option
end
end
end