diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-26 00:12:17 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-28 10:45:34 -0700 |
| commit | b859baa04737644e40002f511c5941d002a956e3 (patch) | |
| tree | f8f4d581c3b0445df836d5e55945f62547239598 /spec/unit/interface | |
| parent | 88aeb04a50d8997b5e1e0ed7a5a2239508b174ee (diff) | |
MAINT: the API is officially named "string" as of this moment.
Now that we have settled on the final public name for the API,
"Puppet::String", mass-rename and mass-edit all the files to follow.
Reviewed-By: Randall Hansen <randall@puppetlabs.com>
Diffstat (limited to 'spec/unit/interface')
| -rw-r--r-- | spec/unit/interface/action_builder_spec.rb | 30 | ||||
| -rwxr-xr-x | spec/unit/interface/action_manager_spec.rb | 216 | ||||
| -rw-r--r-- | spec/unit/interface/action_spec.rb | 75 | ||||
| -rw-r--r-- | spec/unit/interface/catalog_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_request_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_revocation_list_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/certificate_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/config_spec.rb | 24 | ||||
| -rw-r--r-- | spec/unit/interface/configurer_spec.rb | 24 | ||||
| -rw-r--r-- | spec/unit/interface/facts_spec.rb | 21 | ||||
| -rw-r--r-- | spec/unit/interface/file_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/indirector_spec.rb | 55 | ||||
| -rw-r--r-- | spec/unit/interface/interface_collection_spec.rb | 249 | ||||
| -rw-r--r-- | spec/unit/interface/key_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/node_spec.rb | 9 | ||||
| -rw-r--r-- | spec/unit/interface/report_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/resource_spec.rb | 6 | ||||
| -rw-r--r-- | spec/unit/interface/resource_type_spec.rb | 6 |
18 files changed, 0 insertions, 757 deletions
diff --git a/spec/unit/interface/action_builder_spec.rb b/spec/unit/interface/action_builder_spec.rb deleted file mode 100644 index 27e817fe9..000000000 --- a/spec/unit/interface/action_builder_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/action_builder' - -describe Puppet::Interface::ActionBuilder do - describe "::build" do - it "should build an action" do - action = Puppet::Interface::ActionBuilder.build(nil,:foo) do - end - action.should be_a(Puppet::Interface::Action) - action.name.should == "foo" - end - - it "should define a method on the interface which invokes the action" do - interface = Puppet::Interface.new(:action_builder_test_interface, '0.0.1') - action = Puppet::Interface::ActionBuilder.build(interface, :foo) do - invoke do - "invoked the method" - end - end - - interface.foo.should == "invoked the method" - end - - it "should require a block" do - lambda { Puppet::Interface::ActionBuilder.build(nil,:foo) }.should raise_error("Action 'foo' must specify a block") - end - end -end diff --git a/spec/unit/interface/action_manager_spec.rb b/spec/unit/interface/action_manager_spec.rb deleted file mode 100755 index 3aff7ac11..000000000 --- a/spec/unit/interface/action_manager_spec.rb +++ /dev/null @@ -1,216 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -# 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::Interface::ActionManager -end - -describe Puppet::Interface::ActionManager do - subject { ActionManagerTester.new } - - describe "when included in a class" do - it "should be able to define an action" do - subject.action(:foo) do - invoke { "something "} - end - end - - it "should be able to define a 'script' style action" do - subject.script :bar do - "a bar is where beer is found" - end - end - - it "should be able to list defined actions" do - subject.action(:foo) do - invoke { "something" } - end - subject.action(:bar) do - invoke { "something" } - end - - subject.actions.should =~ [:foo, :bar] - end - - it "should list 'script' actions" do - subject.script :foo do "foo" end - subject.actions.should =~ [:foo] - end - - it "should list both script and normal actions" do - subject.action :foo do - invoke do "foo" end - end - subject.script :bar do "a bar is where beer is found" end - - subject.actions.should =~ [:foo, :bar] - end - - it "should be able to indicate when an action is defined" do - subject.action(:foo) do - invoke { "something" } - end - - subject.should be_action(:foo) - end - - it "should indicate an action is defined for script actions" do - subject.script :foo do "foo" end - subject.should be_action :foo - end - - it "should correctly treat action names specified as strings" do - subject.action(:foo) do - invoke { "something" } - end - - subject.should be_action("foo") - end - end - - describe "when used to extend a class" do - subject { Class.new.extend(Puppet::Interface::ActionManager) } - - it "should be able to define an action" do - subject.action(:foo) do - invoke { "something "} - end - end - - it "should be able to list defined actions" do - subject.action(:foo) do - invoke { "something" } - end - subject.action(:bar) do - invoke { "something" } - end - - subject.actions.should include(:bar) - subject.actions.should include(:foo) - end - - it "should be able to indicate when an action is defined" do - subject.action(:foo) { "something" } - subject.should be_action(:foo) - end - end - - describe "when used both at the class and instance level" do - before do - @klass = Class.new do - include Puppet::Interface::ActionManager - extend Puppet::Interface::ActionManager - end - @instance = @klass.new - end - - it "should be able to define an action at the class level" do - @klass.action(:foo) do - invoke { "something "} - end - end - - it "should create an instance method when an action is defined at the class level" do - @klass.action(:foo) do - invoke { "something" } - end - @instance.foo.should == "something" - end - - it "should be able to define an action at the instance level" do - @instance.action(:foo) do - invoke { "something "} - end - end - - it "should create an instance method when an action is defined at the instance level" do - @instance.action(:foo) do - invoke { "something" } - end - @instance.foo.should == "something" - end - - it "should be able to list actions defined at the class level" do - @klass.action(:foo) do - invoke { "something" } - end - @klass.action(:bar) do - invoke { "something" } - end - - @klass.actions.should include(:bar) - @klass.actions.should include(:foo) - end - - it "should be able to list actions defined at the instance level" do - @instance.action(:foo) do - invoke { "something" } - end - @instance.action(:bar) do - invoke { "something" } - end - - @instance.actions.should include(:bar) - @instance.actions.should include(:foo) - end - - it "should be able to list actions defined at both instance and class level" do - @klass.action(:foo) do - invoke { "something" } - end - @instance.action(:bar) do - invoke { "something" } - end - - @instance.actions.should include(:bar) - @instance.actions.should include(:foo) - end - - it "should be able to indicate when an action is defined at the class level" do - @klass.action(:foo) do - invoke { "something" } - end - @instance.should be_action(:foo) - end - - it "should be able to indicate when an action is defined at the instance level" do - @klass.action(:foo) do - invoke { "something" } - end - @instance.should be_action(:foo) - end - - it "should list actions defined in superclasses" do - @subclass = Class.new(@klass) - @instance = @subclass.new - - @klass.action(:parent) do - invoke { "a" } - end - @subclass.action(:sub) do - invoke { "a" } - end - @instance.action(:instance) do - invoke { "a" } - end - - @instance.should be_action(:parent) - @instance.should be_action(:sub) - @instance.should be_action(:instance) - end - - it "should create an instance method when an action is defined in a superclass" do - @subclass = Class.new(@klass) - @instance = @subclass.new - - @klass.action(:foo) do - invoke { "something" } - end - @instance.foo.should == "something" - end - end -end diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb deleted file mode 100644 index 292caabb9..000000000 --- a/spec/unit/interface/action_spec.rb +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/action' - -describe Puppet::Interface::Action do - describe "when validating the action name" do - it "should require a name" do - lambda { Puppet::Interface::Action.new(nil,nil) }.should raise_error("'' is an invalid action name") - end - - it "should not allow empty names" do - lambda { Puppet::Interface::Action.new(nil,'') }.should raise_error("'' is an invalid action name") - end - - it "should not allow names with whitespace" do - lambda { Puppet::Interface::Action.new(nil,'foo bar') }.should raise_error("'foo bar' is an invalid action name") - end - - it "should not allow names beginning with dashes" do - lambda { Puppet::Interface::Action.new(nil,'-foobar') }.should raise_error("'-foobar' is an invalid action name") - end - end - - describe "when invoking" do - it "should be able to call other actions on the same object" do - interface = Puppet::Interface.new(:my_interface, '0.0.1') do - action(:foo) do - invoke { 25 } - end - - action(:bar) do - invoke { "the value of foo is '#{foo}'" } - end - end - interface.foo.should == 25 - interface.bar.should == "the value of foo is '25'" - end - - # bar is a class action calling a class action - # quux is a class action calling an instance action - # 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::Interface::MyInterfaceBaseClass < Puppet::Interface - action(:foo) do - invoke { 25 } - end - - action(:bar) do - invoke { "the value of foo is '#{foo}'" } - end - - action(:quux) do - invoke { "qux told me #{qux}" } - end - end - - interface = Puppet::Interface::MyInterfaceBaseClass.new(:my_inherited_interface, '0.0.1') do - action(:baz) do - invoke { "the value of foo in baz is '#{foo}'" } - end - - action(:qux) do - invoke { baz } - end - end - interface.foo.should == 25 - interface.bar.should == "the value of foo is '25'" - interface.quux.should == "qux told me the value of foo in baz is '25'" - interface.baz.should == "the value of foo in baz is '25'" - interface.qux.should == "the value of foo in baz is '25'" - end - end -end diff --git a/spec/unit/interface/catalog_spec.rb b/spec/unit/interface/catalog_spec.rb deleted file mode 100644 index c615181ed..000000000 --- a/spec/unit/interface/catalog_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:catalog, '0.0.1') do -end diff --git a/spec/unit/interface/certificate_request_spec.rb b/spec/unit/interface/certificate_request_spec.rb deleted file mode 100644 index 0143ebc85..000000000 --- a/spec/unit/interface/certificate_request_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:certificate_request, '0.0.1') do -end diff --git a/spec/unit/interface/certificate_revocation_list_spec.rb b/spec/unit/interface/certificate_revocation_list_spec.rb deleted file mode 100644 index 9655dd3fa..000000000 --- a/spec/unit/interface/certificate_revocation_list_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:certificate_revocation_list, '0.0.1') do -end diff --git a/spec/unit/interface/certificate_spec.rb b/spec/unit/interface/certificate_spec.rb deleted file mode 100644 index e5c63e456..000000000 --- a/spec/unit/interface/certificate_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:certificate, '0.0.1') do -end diff --git a/spec/unit/interface/config_spec.rb b/spec/unit/interface/config_spec.rb deleted file mode 100644 index 2e82b0b08..000000000 --- a/spec/unit/interface/config_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:config, '0.0.1') do - it "should use Settings#print_config_options when asked to print" do - Puppet.settings.stubs(:puts) - Puppet.settings.expects(:print_config_options) - subject.print - end - - it "should set 'configprint' to all desired values and call print_config_options when a specific value is provided" do - Puppet.settings.stubs(:puts) - Puppet.settings.expects(:print_config_options) - subject.print("libdir", "ssldir") - Puppet.settings[:configprint].should == "libdir,ssldir" - end - - it "should always return nil" do - Puppet.settings.stubs(:puts) - Puppet.settings.expects(:print_config_options) - subject.print("libdir").should be_nil - end -end diff --git a/spec/unit/interface/configurer_spec.rb b/spec/unit/interface/configurer_spec.rb deleted file mode 100644 index e97e63b65..000000000 --- a/spec/unit/interface/configurer_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/indirector/catalog/rest' -require 'tempfile' - -describe Puppet::Interface.define(:configurer, '0.0.1') do - describe "#synchronize" do - it "should retrieve and apply a catalog and return a report" do - dirname = Dir.mktmpdir("puppetdir") - Puppet[:vardir] = dirname - Puppet[:confdir] = dirname - @catalog = Puppet::Resource::Catalog.new - @file = Puppet::Resource.new(:file, File.join(dirname, "tmp_dir_resource"), :parameters => {:ensure => :present}) - @catalog.add_resource(@file) - Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog) - - report = subject.synchronize("foo") - - report.kind.should == "apply" - report.status.should == "changed" - end - end -end diff --git a/spec/unit/interface/facts_spec.rb b/spec/unit/interface/facts_spec.rb deleted file mode 100644 index 5f0214fd5..000000000 --- a/spec/unit/interface/facts_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:facts, '0.0.1') do - it "should define an 'upload' fact" do - subject.should be_action(:upload) - end - - it "should set its default format to :yaml" do - subject.default_format.should == :yaml - end - - describe "when uploading" do - it "should set the terminus_class to :facter" - - it "should set the cach_eclass to :rest" - - it "should find the current certname" - end -end diff --git a/spec/unit/interface/file_spec.rb b/spec/unit/interface/file_spec.rb deleted file mode 100644 index bd6e31c0e..000000000 --- a/spec/unit/interface/file_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:file, '0.0.1') do -end diff --git a/spec/unit/interface/indirector_spec.rb b/spec/unit/interface/indirector_spec.rb deleted file mode 100644 index 4b2beaefc..000000000 --- a/spec/unit/interface/indirector_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'puppet/interface/indirector' - -describe Puppet::Interface::Indirector do - before do - @instance = Puppet::Interface::Indirector.new(:test, '0.0.1') - - @indirection = stub 'indirection', :name => :stub_indirection - - @instance.stubs(:indirection).returns @indirection - end - - it "should be able to return a list of indirections" do - Puppet::Interface::Indirector.indirections.should be_include("catalog") - end - - it "should be able to return a list of terminuses for a given indirection" do - Puppet::Interface::Indirector.terminus_classes(:catalog).should be_include("compiler") - end - - describe "as an instance" do - it "should be able to determine its indirection" do - # Loading actions here an get, um, complicated - Puppet::Interface.stubs(:load_actions) - Puppet::Interface::Indirector.new(:catalog, '0.0.1').indirection.should equal(Puppet::Resource::Catalog.indirection) - end - end - - [:find, :search, :save, :destroy].each do |method| - it "should define a '#{method}' action" do - Puppet::Interface::Indirector.should be_action(method) - end - - it "should just call the indirection method when the '#{method}' action is invoked" do - @instance.indirection.expects(method).with(:test, "myargs") - @instance.send(method, :test, "myargs") - end - end - - it "should be able to override its indirection name" do - @instance.set_indirection_name :foo - @instance.indirection_name.should == :foo - end - - it "should be able to set its terminus class" do - @instance.indirection.expects(:terminus_class=).with(:myterm) - @instance.set_terminus(:myterm) - end - - it "should define a class-level 'info' action" do - Puppet::Interface::Indirector.should be_action(:info) - end -end diff --git a/spec/unit/interface/interface_collection_spec.rb b/spec/unit/interface/interface_collection_spec.rb deleted file mode 100644 index 3e4b9d624..000000000 --- a/spec/unit/interface/interface_collection_spec.rb +++ /dev/null @@ -1,249 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'tmpdir' - -describe Puppet::Interface::InterfaceCollection do - before :all do - @interfaces = subject.instance_variable_get("@interfaces").dup - end - - before :each do - subject.instance_variable_get("@interfaces").clear - end - - after :all do - subject.instance_variable_set("@interfaces", @interfaces) - end - - describe "::interfaces" do - end - - describe "::versions" do - before :each do - @dir = Dir.mktmpdir - @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'interface') - $LOAD_PATH.push(@dir) - end - - after :each do - FileUtils.remove_entry_secure @dir - $LOAD_PATH.pop - end - - it "should return an empty array when no versions are loadable" do - subject.versions(:fozzie).should == [] - end - - it "should return versions loadable as puppet/interface/v{version}/{name}" do - FileUtils.mkdir_p(File.join @lib, 'v1.0.0') - FileUtils.touch(File.join @lib, 'v1.0.0', 'fozzie.rb') - subject.versions(:fozzie).should == ['1.0.0'] - end - - it "should an ordered list of all versions loadable as puppet/interface/v{version}/{name}" do - %w[ 1.2.1rc2 1.2.1beta1 1.2.1rc1 1.2.1 1.2.2 ].each do |version| - FileUtils.mkdir_p(File.join @lib, "v#{version}") - FileUtils.touch(File.join @lib, "v#{version}", 'fozzie.rb') - end - subject.versions(:fozzie).should == %w[ 1.2.1beta1 1.2.1rc1 1.2.1rc2 1.2.1 1.2.2 ] - end - - it "should not return a version for an empty puppet/interface/v{version}/{name}" do - FileUtils.mkdir_p(File.join @lib, 'v1.0.0', 'fozzie') - subject.versions(:fozzie).should == [] - end - - it "should an ordered list of all versions loadable as puppet/interface/v{version}/{name}/*.rb" do - %w[ 1.2.1rc2 1.2.1beta1 1.2.1rc1 1.2.1 1.2.2 ].each do |version| - FileUtils.mkdir_p(File.join @lib, "v#{version}", "fozzie") - FileUtils.touch(File.join @lib, "v#{version}", 'fozzie', 'action.rb') - end - subject.versions(:fozzie).should == %w[ 1.2.1beta1 1.2.1rc1 1.2.1rc2 1.2.1 1.2.2 ] - end - end - - describe "::validate_version" do - it 'should permit three number versions' do - subject.validate_version('10.10.10').should == true - end - - it 'should permit versions with appended descriptions' do - subject.validate_version('10.10.10beta').should == true - end - - it 'should not permit versions with more than three numbers' do - subject.validate_version('1.2.3.4').should == false - end - - it 'should not permit versions with only two numbers' do - subject.validate_version('10.10').should == false - end - - it 'should not permit versions with only one number' do - subject.validate_version('123').should == false - end - - it 'should not permit versions with text in any position but at the end' do - subject.validate_version('v1.1.1').should == false - end - end - - describe "::compare_versions" do - # (a <=> b) should be: - # -1 if a < b - # 0 if a == b - # 1 if a > b - it 'should sort major version numbers numerically' do - subject.compare_versions('1.0.0', '2.0.0').should == -1 - subject.compare_versions('2.0.0', '1.1.1').should == 1 - subject.compare_versions('2.0.0', '10.0.0').should == -1 - end - - it 'should sort minor version numbers numerically' do - subject.compare_versions('0.1.0', '0.2.0').should == -1 - subject.compare_versions('0.2.0', '0.1.1').should == 1 - subject.compare_versions('0.2.0', '0.10.0').should == -1 - end - - it 'should sort tiny version numbers numerically' do - subject.compare_versions('0.0.1', '0.0.2').should == -1 - subject.compare_versions('0.0.2', '0.0.1').should == 1 - subject.compare_versions('0.0.2', '0.0.10').should == -1 - end - - it 'should sort major version before minor version' do - subject.compare_versions('1.1.0', '1.2.0').should == -1 - subject.compare_versions('1.2.0', '1.1.1').should == 1 - subject.compare_versions('1.2.0', '1.10.0').should == -1 - - subject.compare_versions('1.1.0', '2.2.0').should == -1 - subject.compare_versions('2.2.0', '1.1.1').should == 1 - subject.compare_versions('2.2.0', '1.10.0').should == 1 - end - - it 'should sort minor version before tiny version' do - subject.compare_versions('0.1.1', '0.1.2').should == -1 - subject.compare_versions('0.1.2', '0.1.1').should == 1 - subject.compare_versions('0.1.2', '0.1.10').should == -1 - - subject.compare_versions('0.1.1', '0.2.2').should == -1 - subject.compare_versions('0.2.2', '0.1.1').should == 1 - subject.compare_versions('0.2.2', '0.1.10').should == 1 - end - - it 'should sort appended strings asciibetically' do - subject.compare_versions('0.0.0a', '0.0.0b').should == -1 - subject.compare_versions('0.0.0beta1', '0.0.0beta2').should == -1 - subject.compare_versions('0.0.0beta1', '0.0.0rc1').should == -1 - subject.compare_versions('0.0.0beta1', '0.0.0alpha1').should == 1 - subject.compare_versions('0.0.0beta1', '0.0.0beta1').should == 0 - end - - it "should sort appended strings before 'whole' versions" do - subject.compare_versions('0.0.1a', '0.0.1').should == -1 - subject.compare_versions('0.0.1', '0.0.1beta').should == 1 - end - end - - describe "::[]" do - before :each do - subject.instance_variable_get("@interfaces")[:foo]['0.0.1'] = 10 - end - - before :each do - @dir = Dir.mktmpdir - @lib = FileUtils.mkdir_p(File.join @dir, 'puppet', 'interface') - $LOAD_PATH.push(@dir) - end - - after :each do - FileUtils.remove_entry_secure @dir - $LOAD_PATH.pop - end - - it "should return the interface with the given name" do - subject["foo", '0.0.1'].should == 10 - end - - it "should attempt to load the interface if it isn't found" do - subject.expects(:require).with('puppet/interface/v0.0.1/bar') - subject["bar", '0.0.1'] - end - - it "should attempt to load the interface with the greatest version for specified version :latest" do - %w[ 1.2.1 1.2.2 ].each do |version| - FileUtils.mkdir_p(File.join @lib, "v#{version}") - FileUtils.touch(File.join @lib, "v#{version}", 'fozzie.rb') - end - subject.expects(:require).with('puppet/interface/v1.2.2/fozzie') - subject['fozzie', :latest] - end - end - - describe "::interface?" do - before :each do - subject.instance_variable_get("@interfaces")[:foo]['0.0.1'] = 10 - end - - it "should return true if the interface specified is registered" do - subject.interface?("foo", '0.0.1').should == true - end - - it "should attempt to require the interface if it is not registered" do - subject.expects(:require).with('puppet/interface/v0.0.1/bar') - subject.interface?("bar", '0.0.1') - end - - it "should return true if requiring the interface registered it" do - subject.stubs(:require).with do - subject.instance_variable_get("@interfaces")[:bar]['0.0.1'] = 20 - end - subject.interface?("bar", '0.0.1').should == true - end - - it "should return false if the interface is not registered" do - subject.stubs(:require).returns(true) - subject.interface?("bar", '0.0.1').should == false - end - - it "should return false if there is a LoadError requiring the interface" do - subject.stubs(:require).raises(LoadError) - subject.interface?("bar", '0.0.1').should == false - end - end - - describe "::register" do - it "should store the interface by name" do - interface = Puppet::Interface.new(:my_interface, '0.0.1') - subject.register(interface) - subject.instance_variable_get("@interfaces").should == {:my_interface => {'0.0.1' => interface}} - end - end - - describe "::underscorize" do - faulty = [1, "#foo", "$bar", "sturm und drang", :"sturm und drang"] - valid = { - "Foo" => :foo, - :Foo => :foo, - "foo_bar" => :foo_bar, - :foo_bar => :foo_bar, - "foo-bar" => :foo_bar, - :"foo-bar" => :foo_bar, - } - - valid.each do |input, expect| - it "should map #{input.inspect} to #{expect.inspect}" do - result = subject.underscorize(input) - result.should == expect - end - end - - faulty.each do |input| - it "should fail when presented with #{input.inspect} (#{input.class})" do - expect { subject.underscorize(input) }. - should raise_error ArgumentError, /not a valid interface name/ - end - end - end -end diff --git a/spec/unit/interface/key_spec.rb b/spec/unit/interface/key_spec.rb deleted file mode 100644 index 519497808..000000000 --- a/spec/unit/interface/key_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:key, '0.0.1') do -end diff --git a/spec/unit/interface/node_spec.rb b/spec/unit/interface/node_spec.rb deleted file mode 100644 index 91914c3ae..000000000 --- a/spec/unit/interface/node_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:node, '0.0.1') do - it "should set its default format to :yaml" do - subject.default_format.should == :yaml - end -end diff --git a/spec/unit/interface/report_spec.rb b/spec/unit/interface/report_spec.rb deleted file mode 100644 index 23855db09..000000000 --- a/spec/unit/interface/report_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:report, '0.0.1') do -end diff --git a/spec/unit/interface/resource_spec.rb b/spec/unit/interface/resource_spec.rb deleted file mode 100644 index 408be250c..000000000 --- a/spec/unit/interface/resource_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:resource, '0.0.1') do -end diff --git a/spec/unit/interface/resource_type_spec.rb b/spec/unit/interface/resource_type_spec.rb deleted file mode 100644 index 860be282c..000000000 --- a/spec/unit/interface/resource_type_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -describe Puppet::Interface.define(:resource_type, '0.0.1') do -end |
