summaryrefslogtreecommitdiffstats
path: root/spec/unit/indirector
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/indirector')
-rwxr-xr-xspec/unit/indirector/checksum/file.rb (renamed from spec/unit/indirector/file/checksum.rb)22
-rwxr-xr-xspec/unit/indirector/code.rb2
-rwxr-xr-xspec/unit/indirector/configuration/compiler.rb (renamed from spec/unit/indirector/code/configuration.rb)30
-rwxr-xr-xspec/unit/indirector/configuration/yaml.rb25
-rwxr-xr-xspec/unit/indirector/exec.rb4
-rwxr-xr-xspec/unit/indirector/facts/facter.rb (renamed from spec/unit/indirector/code/facts.rb)22
-rwxr-xr-xspec/unit/indirector/facts/yaml.rb (renamed from spec/unit/indirector/yaml/facts.rb)12
-rwxr-xr-xspec/unit/indirector/file.rb2
-rwxr-xr-xspec/unit/indirector/indirection.rb16
-rwxr-xr-xspec/unit/indirector/indirector.rb2
-rwxr-xr-xspec/unit/indirector/ldap.rb4
-rwxr-xr-xspec/unit/indirector/memory.rb2
-rwxr-xr-xspec/unit/indirector/node/exec.rb (renamed from spec/unit/indirector/exec/node.rb)10
-rwxr-xr-xspec/unit/indirector/node/ldap.rb (renamed from spec/unit/indirector/ldap/node.rb)16
-rwxr-xr-xspec/unit/indirector/node/memory.rb (renamed from spec/unit/indirector/memory/node.rb)6
-rwxr-xr-xspec/unit/indirector/node/null.rb (renamed from spec/unit/indirector/null/node.rb)6
-rwxr-xr-xspec/unit/indirector/node/rest.rb13
-rwxr-xr-xspec/unit/indirector/node/yaml.rb (renamed from spec/unit/indirector/yaml/node.rb)12
-rwxr-xr-xspec/unit/indirector/null.rb2
-rwxr-xr-xspec/unit/indirector/report/processor.rb (renamed from spec/unit/indirector/code/report.rb)14
-rwxr-xr-xspec/unit/indirector/rest/node.rb13
-rwxr-xr-xspec/unit/indirector/terminus.rb143
-rwxr-xr-xspec/unit/indirector/yaml.rb2
-rwxr-xr-xspec/unit/indirector/yaml/configuration.rb25
24 files changed, 204 insertions, 201 deletions
diff --git a/spec/unit/indirector/file/checksum.rb b/spec/unit/indirector/checksum/file.rb
index 539bb973c..82319fa40 100755
--- a/spec/unit/indirector/file/checksum.rb
+++ b/spec/unit/indirector/checksum/file.rb
@@ -5,12 +5,12 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/file/checksum'
+require 'puppet/indirector/checksum/file'
module FileChecksumTesting
def setup
Puppet.settings.stubs(:use)
- @store = Puppet::Indirector::File::Checksum.new
+ @store = Puppet::Checksum::File.new
@value = "70924d6fa4b2d745185fa4660703a5c0"
@sum = stub 'sum', :name => @value
@@ -23,24 +23,24 @@ module FileChecksumTesting
end
end
-describe Puppet::Indirector::File::Checksum do
+describe Puppet::Checksum::File do
it "should be a subclass of the File terminus class" do
- Puppet::Indirector::File::Checksum.superclass.should equal(Puppet::Indirector::File)
+ Puppet::Checksum::File.superclass.should equal(Puppet::Indirector::File)
end
it "should have documentation" do
- Puppet::Indirector::File::Checksum.doc.should be_instance_of(String)
+ Puppet::Checksum::File.doc.should be_instance_of(String)
end
end
-describe Puppet::Indirector::File::Checksum, " when initializing" do
+describe Puppet::Checksum::File, " when initializing" do
it "should use the filebucket settings section" do
Puppet.settings.expects(:use).with(:filebucket)
- Puppet::Indirector::File::Checksum.new
+ Puppet::Checksum::File.new
end
end
-describe Puppet::Indirector::File::Checksum, " when determining file paths" do
+describe Puppet::Checksum::File, " when determining file paths" do
include FileChecksumTesting
# I was previously passing the object in.
@@ -71,7 +71,7 @@ describe Puppet::Indirector::File::Checksum, " when determining file paths" do
end
end
-describe Puppet::Indirector::File::Checksum, " when retrieving files" do
+describe Puppet::Checksum::File, " when retrieving files" do
include FileChecksumTesting
# The smallest test that will use the calculated path
@@ -103,7 +103,7 @@ describe Puppet::Indirector::File::Checksum, " when retrieving files" do
end
end
-describe Puppet::Indirector::File::Checksum, " when saving files" do
+describe Puppet::Checksum::File, " when saving files" do
include FileChecksumTesting
# LAK:FIXME I don't know how to include in the spec the fact that we're
@@ -129,7 +129,7 @@ describe Puppet::Indirector::File::Checksum, " when saving files" do
end
end
-describe Puppet::Indirector::File::Checksum, " when deleting files" do
+describe Puppet::Checksum::File, " when deleting files" do
include FileChecksumTesting
it "should remove the file at the calculated path" do
diff --git a/spec/unit/indirector/code.rb b/spec/unit/indirector/code.rb
index f34dcf402..3eb7540ef 100755
--- a/spec/unit/indirector/code.rb
+++ b/spec/unit/indirector/code.rb
@@ -12,7 +12,7 @@ describe Puppet::Indirector::Code do
@code_class = Class.new(Puppet::Indirector::Code) do
def self.to_s
- "Testing"
+ "Mystuff::Testing"
end
end
diff --git a/spec/unit/indirector/code/configuration.rb b/spec/unit/indirector/configuration/compiler.rb
index b2a23ac19..cb9dc7162 100755
--- a/spec/unit/indirector/code/configuration.rb
+++ b/spec/unit/indirector/configuration/compiler.rb
@@ -5,9 +5,9 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/code/configuration'
+require 'puppet/indirector/configuration/compiler'
-describe Puppet::Indirector::Code::Configuration do
+describe Puppet::Node::Configuration::Compiler do
before do
Puppet.expects(:version).returns(1)
Facter.expects(:value).with('fqdn').returns("my.server.com")
@@ -15,11 +15,11 @@ describe Puppet::Indirector::Code::Configuration do
end
it "should gather data about itself" do
- Puppet::Indirector::Code::Configuration.new
+ Puppet::Node::Configuration::Compiler.new
end
it "should cache the server metadata and reuse it" do
- compiler = Puppet::Indirector::Code::Configuration.new
+ compiler = Puppet::Node::Configuration::Compiler.new
node1 = stub 'node1', :merge => nil
node2 = stub 'node2', :merge => nil
compiler.stubs(:compile)
@@ -31,16 +31,16 @@ describe Puppet::Indirector::Code::Configuration do
end
it "should provide a method for determining if the configuration is networked" do
- compiler = Puppet::Indirector::Code::Configuration.new
+ compiler = Puppet::Node::Configuration::Compiler.new
compiler.should respond_to(:networked?)
end
end
-describe Puppet::Indirector::Code::Configuration, " when creating the interpreter" do
+describe Puppet::Node::Configuration::Compiler, " when creating the interpreter" do
before do
# This gets pretty annoying on a plane where we have no IP address
Facter.stubs(:value).returns("whatever")
- @compiler = Puppet::Indirector::Code::Configuration.new
+ @compiler = Puppet::Node::Configuration::Compiler.new
end
it "should not create the interpreter until it is asked for the first time" do
@@ -57,10 +57,10 @@ describe Puppet::Indirector::Code::Configuration, " when creating the interprete
end
end
-describe Puppet::Indirector::Code::Configuration, " when finding nodes" do
+describe Puppet::Node::Configuration::Compiler, " when finding nodes" do
before do
Facter.stubs(:value).returns("whatever")
- @compiler = Puppet::Indirector::Code::Configuration.new
+ @compiler = Puppet::Node::Configuration::Compiler.new
@name = "me"
@node = mock 'node'
@compiler.stubs(:compile)
@@ -79,13 +79,13 @@ describe Puppet::Indirector::Code::Configuration, " when finding nodes" do
end
end
-describe Puppet::Indirector::Code::Configuration, " after finding nodes" do
+describe Puppet::Node::Configuration::Compiler, " after finding nodes" do
before do
Puppet.expects(:version).returns(1)
Puppet.settings.stubs(:value).with(:node_name).returns("cert")
Facter.expects(:value).with('fqdn').returns("my.server.com")
Facter.expects(:value).with('ipaddress').returns("my.ip.address")
- @compiler = Puppet::Indirector::Code::Configuration.new
+ @compiler = Puppet::Node::Configuration::Compiler.new
@name = "me"
@node = mock 'node'
@compiler.stubs(:compile)
@@ -115,10 +115,10 @@ describe Puppet::Indirector::Code::Configuration, " after finding nodes" do
end
end
-describe Puppet::Indirector::Code::Configuration, " when creating configurations" do
+describe Puppet::Node::Configuration::Compiler, " when creating configurations" do
before do
Facter.stubs(:value).returns("whatever")
- @compiler = Puppet::Indirector::Code::Configuration.new
+ @compiler = Puppet::Node::Configuration::Compiler.new
@name = "me"
@node = Puppet::Node.new @name, :environment => "yay"
@node.stubs(:merge)
@@ -155,11 +155,11 @@ describe Puppet::Indirector::Code::Configuration, " when creating configurations
end
end
-describe Puppet::Indirector::Code::Configuration, " when determining a client's available configuration version" do
+describe Puppet::Node::Configuration::Compiler, " when determining a client's available configuration version" do
before do
Puppet::Node::Facts.stubs(:find).returns(nil)
Facter.stubs(:value).returns("whatever")
- @configuration = Puppet::Indirector::Code::Configuration.new
+ @configuration = Puppet::Node::Configuration::Compiler.new
@name = "johnny"
end
diff --git a/spec/unit/indirector/configuration/yaml.rb b/spec/unit/indirector/configuration/yaml.rb
new file mode 100755
index 000000000..b9f3f40d1
--- /dev/null
+++ b/spec/unit/indirector/configuration/yaml.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+require 'puppet/node/configuration'
+require 'puppet/indirector/configuration/yaml'
+
+describe Puppet::Node::Configuration::Yaml do
+ it "should be a subclass of the Yaml terminus" do
+ Puppet::Node::Configuration::Yaml.superclass.should equal(Puppet::Indirector::Yaml)
+ end
+
+ it "should have documentation" do
+ Puppet::Node::Configuration::Yaml.doc.should_not be_nil
+ end
+
+ it "should be registered with the configuration store indirection" do
+ indirection = Puppet::Indirector::Indirection.instance(:configuration)
+ Puppet::Node::Configuration::Yaml.indirection.should equal(indirection)
+ end
+
+ it "should have its name set to :yaml" do
+ Puppet::Node::Configuration::Yaml.name.should == :yaml
+ end
+end
diff --git a/spec/unit/indirector/exec.rb b/spec/unit/indirector/exec.rb
index 42fbe0955..3baf06629 100755
--- a/spec/unit/indirector/exec.rb
+++ b/spec/unit/indirector/exec.rb
@@ -6,11 +6,11 @@ require 'puppet/indirector/exec'
describe Puppet::Indirector::Exec do
before do
- @indirection = mock 'indirection'
+ @indirection = stub 'indirection', :name => :testing
Puppet::Indirector::Indirection.expects(:instance).with(:testing).returns(@indirection)
@exec_class = Class.new(Puppet::Indirector::Exec) do
def self.to_s
- "Testing"
+ "Testing::Mytype"
end
attr_accessor :command
diff --git a/spec/unit/indirector/code/facts.rb b/spec/unit/indirector/facts/facter.rb
index 9b645617f..e8ea721d3 100755
--- a/spec/unit/indirector/code/facts.rb
+++ b/spec/unit/indirector/facts/facter.rb
@@ -5,37 +5,37 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/code/facts'
+require 'puppet/indirector/facts/facter'
-describe Puppet::Indirector::Code::Facts do
+describe Puppet::Node::Facts::Facter do
it "should be a subclass of the Code terminus" do
- Puppet::Indirector::Code::Facts.superclass.should equal(Puppet::Indirector::Code)
+ Puppet::Node::Facts::Facter.superclass.should equal(Puppet::Indirector::Code)
end
it "should have documentation" do
- Puppet::Indirector::Code::Facts.doc.should_not be_nil
+ Puppet::Node::Facts::Facter.doc.should_not be_nil
end
it "should be registered with the configuration store indirection" do
indirection = Puppet::Indirector::Indirection.instance(:facts)
- Puppet::Indirector::Code::Facts.indirection.should equal(indirection)
+ Puppet::Node::Facts::Facter.indirection.should equal(indirection)
end
- it "should have its name set to :facts" do
- Puppet::Indirector::Code::Facts.name.should == :facts
+ it "should have its name set to :facter" do
+ Puppet::Node::Facts::Facter.name.should == :facter
end
end
module TestingCodeFacts
def setup
- @facter = Puppet::Indirector::Code::Facts.new
+ @facter = Puppet::Node::Facts::Facter.new
Facter.stubs(:to_hash).returns({})
@name = "me"
@facts = @facter.find(@name)
end
end
-describe Puppet::Indirector::Code::Facts, " when finding facts" do
+describe Puppet::Node::Facts::Facter, " when finding facts" do
include TestingCodeFacts
it "should return a Facts instance" do
@@ -53,7 +53,7 @@ describe Puppet::Indirector::Code::Facts, " when finding facts" do
end
end
-describe Puppet::Indirector::Code::Facts, " when saving facts" do
+describe Puppet::Node::Facts::Facter, " when saving facts" do
include TestingCodeFacts
it "should fail" do
@@ -61,7 +61,7 @@ describe Puppet::Indirector::Code::Facts, " when saving facts" do
end
end
-describe Puppet::Indirector::Code::Facts, " when destroying facts" do
+describe Puppet::Node::Facts::Facter, " when destroying facts" do
include TestingCodeFacts
it "should fail" do
diff --git a/spec/unit/indirector/yaml/facts.rb b/spec/unit/indirector/facts/yaml.rb
index f1256cfa4..8b49fa3b5 100755
--- a/spec/unit/indirector/yaml/facts.rb
+++ b/spec/unit/indirector/facts/yaml.rb
@@ -3,24 +3,24 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/node/facts'
-require 'puppet/indirector/yaml/facts'
+require 'puppet/indirector/facts/yaml'
-describe Puppet::Indirector::Yaml::Facts do
+describe Puppet::Node::Facts::Yaml do
it "should be a subclass of the Yaml terminus" do
- Puppet::Indirector::Yaml::Facts.superclass.should equal(Puppet::Indirector::Yaml)
+ Puppet::Node::Facts::Yaml.superclass.should equal(Puppet::Indirector::Yaml)
end
it "should have documentation" do
- Puppet::Indirector::Yaml::Facts.doc.should_not be_nil
+ Puppet::Node::Facts::Yaml.doc.should_not be_nil
end
it "should be registered with the facts indirection" do
indirection = Puppet::Indirector::Indirection.instance(:facts)
- Puppet::Indirector::Yaml::Facts.indirection.should equal(indirection)
+ Puppet::Node::Facts::Yaml.indirection.should equal(indirection)
end
it "should have its name set to :facts" do
- Puppet::Indirector::Yaml::Facts.name.should == :facts
+ Puppet::Node::Facts::Yaml.name.should == :yaml
end
end
diff --git a/spec/unit/indirector/file.rb b/spec/unit/indirector/file.rb
index cc86f9fa9..216c9bfe1 100755
--- a/spec/unit/indirector/file.rb
+++ b/spec/unit/indirector/file.rb
@@ -12,7 +12,7 @@ module FileTerminusTesting
@file_class = Class.new(Puppet::Indirector::File) do
def self.to_s
- "Testing"
+ "Testing::Mytype"
end
end
diff --git a/spec/unit/indirector/indirection.rb b/spec/unit/indirector/indirection.rb
index 25152d123..455b5dc67 100755
--- a/spec/unit/indirector/indirection.rb
+++ b/spec/unit/indirector/indirection.rb
@@ -137,17 +137,17 @@ describe Puppet::Indirector::Indirection, " when specifying terminus types" do
end
it "should fail when the specified terminus class cannot be found" do
- Puppet::Indirector::Terminus.expects(:terminus_class).with(:foo, :test).returns(nil)
+ Puppet::Indirector::Terminus.expects(:terminus_class).with(:test, :foo).returns(nil)
proc { @indirection.terminus_class = :foo }.should raise_error(ArgumentError)
end
it "should select the specified terminus class if a terminus class name is provided" do
- Puppet::Indirector::Terminus.expects(:terminus_class).with(:foo, :test).returns(@terminus_class)
+ Puppet::Indirector::Terminus.expects(:terminus_class).with(:test, :foo).returns(@terminus_class)
@indirection.terminus(:foo).should equal(@terminus)
end
it "should use the configured terminus class if no terminus name is specified" do
- Puppet::Indirector::Terminus.stubs(:terminus_class).with(:foo, :test).returns(@terminus_class)
+ Puppet::Indirector::Terminus.stubs(:terminus_class).with(:test, :foo).returns(@terminus_class)
@indirection.terminus_class = :foo
@indirection.terminus().should equal(@terminus)
end
@@ -162,7 +162,7 @@ describe Puppet::Indirector::Indirection, " when managing terminus instances" do
@indirection = Puppet::Indirector::Indirection.new(mock('model'), :test)
@terminus = mock 'terminus'
@terminus_class = mock 'terminus class'
- Puppet::Indirector::Terminus.stubs(:terminus_class).with(:foo, :test).returns(@terminus_class)
+ Puppet::Indirector::Terminus.stubs(:terminus_class).with(:test, :foo).returns(@terminus_class)
end
it "should create an instance of the chosen terminus class" do
@@ -203,7 +203,7 @@ describe Puppet::Indirector::Indirection, " when deciding whether to cache" do
@terminus = mock 'terminus'
@terminus_class = mock 'terminus class'
@terminus_class.stubs(:new).returns(@terminus)
- Puppet::Indirector::Terminus.stubs(:terminus_class).with(:foo, :test).returns(@terminus_class)
+ Puppet::Indirector::Terminus.stubs(:terminus_class).with(:test, :foo).returns(@terminus_class)
@indirection.terminus_class = :foo
end
@@ -224,7 +224,7 @@ describe Puppet::Indirector::Indirection, " when deciding whether to cache" do
end
it "should fail to set the cache class when the specified cache class cannot be found" do
- Puppet::Indirector::Terminus.expects(:terminus_class).with(:foo, :test).returns(nil)
+ Puppet::Indirector::Terminus.expects(:terminus_class).with(:test, :foo).returns(nil)
proc { @indirection.cache_class = :foo }.should raise_error(ArgumentError)
end
@@ -242,8 +242,8 @@ module IndirectionCaching
@terminus_class.stubs(:new).returns(@terminus)
@cache = mock 'cache'
@cache_class = mock 'cache_class'
- Puppet::Indirector::Terminus.stubs(:terminus_class).with(:cache_terminus, :test).returns(@cache_class)
- Puppet::Indirector::Terminus.stubs(:terminus_class).with(:test_terminus, :test).returns(@terminus_class)
+ Puppet::Indirector::Terminus.stubs(:terminus_class).with(:test, :cache_terminus).returns(@cache_class)
+ Puppet::Indirector::Terminus.stubs(:terminus_class).with(:test, :test_terminus).returns(@terminus_class)
@indirection = Puppet::Indirector::Indirection.new(mock('model'), :test)
@indirection.terminus_class = :test_terminus
end
diff --git a/spec/unit/indirector/indirector.rb b/spec/unit/indirector/indirector.rb
index 1f63da30d..64c7bdfca 100755
--- a/spec/unit/indirector/indirector.rb
+++ b/spec/unit/indirector/indirector.rb
@@ -46,7 +46,7 @@ describe Puppet::Indirector, "when registering an indirection" do
it "should allow specification of a default terminus" do
klass = mock 'terminus class'
- Puppet::Indirector::Terminus.stubs(:terminus_class).with(:foo, :first).returns(klass)
+ Puppet::Indirector::Terminus.stubs(:terminus_class).with(:first, :foo).returns(klass)
@indirection = @thingie.indirects :first, :terminus_class => :foo
@indirection.terminus_class.should == :foo
end
diff --git a/spec/unit/indirector/ldap.rb b/spec/unit/indirector/ldap.rb
index fe9408986..6712ccb4f 100755
--- a/spec/unit/indirector/ldap.rb
+++ b/spec/unit/indirector/ldap.rb
@@ -6,11 +6,11 @@ require 'puppet/indirector/ldap'
describe Puppet::Indirector::Ldap, " when searching ldap" do
before do
- @indirection = mock 'indirection'
+ @indirection = stub 'indirection', :name => :testing
Puppet::Indirector::Indirection.stubs(:instance).returns(@indirection)
@ldap_class = Class.new(Puppet::Indirector::Ldap) do
def self.to_s
- "Testing"
+ "Testing::Mytype"
end
end
diff --git a/spec/unit/indirector/memory.rb b/spec/unit/indirector/memory.rb
index ac6f055ce..c0fca6bd9 100755
--- a/spec/unit/indirector/memory.rb
+++ b/spec/unit/indirector/memory.rb
@@ -42,7 +42,7 @@ describe Puppet::Indirector::Memory do
@memory_class = Class.new(Puppet::Indirector::Memory) do
def self.to_s
- "Testing"
+ "Mystuff::Testing"
end
end
diff --git a/spec/unit/indirector/exec/node.rb b/spec/unit/indirector/node/exec.rb
index 47f4ce7a5..744a32b0a 100755
--- a/spec/unit/indirector/exec/node.rb
+++ b/spec/unit/indirector/node/exec.rb
@@ -2,13 +2,13 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/exec/node'
+require 'puppet/indirector/node/exec'
-describe Puppet::Indirector::Exec::Node, " when constructing the command to run" do
+describe Puppet::Node::Exec, " when constructing the command to run" do
before do
@indirection = mock 'indirection'
Puppet.settings.stubs(:value).with(:external_nodes).returns("/echo")
- @searcher = Puppet::Indirector::Exec::Node.new
+ @searcher = Puppet::Node::Exec.new
end
it "should use the external_node script as the command" do
@@ -22,11 +22,11 @@ describe Puppet::Indirector::Exec::Node, " when constructing the command to run"
end
end
-describe Puppet::Indirector::Exec::Node, " when handling the results of the command" do
+describe Puppet::Node::Exec, " when handling the results of the command" do
before do
@indirection = mock 'indirection'
Puppet.settings.stubs(:value).with(:external_nodes).returns("/echo")
- @searcher = Puppet::Indirector::Exec::Node.new
+ @searcher = Puppet::Node::Exec.new
@node = stub 'node', :fact_merge => nil
@name = "yay"
Puppet::Node.expects(:new).with(@name).returns(@node)
diff --git a/spec/unit/indirector/ldap/node.rb b/spec/unit/indirector/node/ldap.rb
index 6667efdd5..8c6888357 100755
--- a/spec/unit/indirector/ldap/node.rb
+++ b/spec/unit/indirector/node/ldap.rb
@@ -2,11 +2,11 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/ldap/node'
+require 'puppet/indirector/node/ldap'
module LdapNodeSearching
def setup
- @searcher = Puppet::Indirector::Ldap::Node.new
+ @searcher = Puppet::Node::Ldap.new
@entries = {}
entries = @entries
@@ -26,7 +26,7 @@ module LdapNodeSearching
end
end
-describe Puppet::Indirector::Ldap::Node, " when searching for nodes" do
+describe Puppet::Node::Ldap, " when searching for nodes" do
include LdapNodeSearching
it "should return nil if no results are found in ldap" do
@@ -82,7 +82,7 @@ describe Puppet::Indirector::Ldap::Node, " when searching for nodes" do
end
end
-describe Puppet::Indirector::Ldap::Node, " when a parent node is specified" do
+describe Puppet::Node::Ldap, " when a parent node is specified" do
include LdapNodeSearching
before do
@@ -169,9 +169,9 @@ describe Puppet::Indirector::Ldap::Node, " when a parent node is specified" do
end
end
-describe Puppet::Indirector::Ldap::Node, " when developing the search query" do
+describe Puppet::Node::Ldap, " when developing the search query" do
before do
- @searcher = Puppet::Indirector::Ldap::Node.new
+ @searcher = Puppet::Node::Ldap.new
end
it "should return the value of the :ldapclassattrs split on commas as the class attributes" do
@@ -208,9 +208,9 @@ describe Puppet::Indirector::Ldap::Node, " when developing the search query" do
end
end
-describe Puppet::Indirector::Ldap::Node, " when deciding attributes to search for" do
+describe Puppet::Node::Ldap, " when deciding attributes to search for" do
before do
- @searcher = Puppet::Indirector::Ldap::Node.new
+ @searcher = Puppet::Node::Ldap.new
end
it "should use 'nil' if the :ldapattrs setting is 'all'" do
diff --git a/spec/unit/indirector/memory/node.rb b/spec/unit/indirector/node/memory.rb
index cba4af53a..f57cae818 100755
--- a/spec/unit/indirector/memory/node.rb
+++ b/spec/unit/indirector/node/memory.rb
@@ -2,16 +2,16 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/memory/node'
+require 'puppet/indirector/node/memory'
# All of our behaviour is described here, so we always have to
# include it.
require 'unit/indirector/memory'
-describe Puppet::Indirector::Memory::Node do
+describe Puppet::Node::Memory do
before do
@name = "me"
- @searcher = Puppet::Indirector::Memory::Node.new
+ @searcher = Puppet::Node::Memory.new
@instance = stub 'instance', :name => @name
end
diff --git a/spec/unit/indirector/null/node.rb b/spec/unit/indirector/node/null.rb
index c589e5820..8125e59a1 100755
--- a/spec/unit/indirector/null/node.rb
+++ b/spec/unit/indirector/node/null.rb
@@ -2,11 +2,11 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/null/node'
+require 'puppet/indirector/node/null'
-describe Puppet::Indirector::Null::Node do
+describe Puppet::Node::Null do
before do
- @searcher = Puppet::Indirector::Null::Node.new
+ @searcher = Puppet::Node::Null.new
end
it "should call node_merge() on the returned node" do
diff --git a/spec/unit/indirector/node/rest.rb b/spec/unit/indirector/node/rest.rb
new file mode 100755
index 000000000..33cfda426
--- /dev/null
+++ b/spec/unit/indirector/node/rest.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+require 'puppet/indirector/node/rest'
+
+describe Puppet::Node::REST do
+ before do
+ @searcher = Puppet::Node::REST.new
+ end
+
+
+end
diff --git a/spec/unit/indirector/yaml/node.rb b/spec/unit/indirector/node/yaml.rb
index a14171b05..2e6c14c71 100755
--- a/spec/unit/indirector/yaml/node.rb
+++ b/spec/unit/indirector/node/yaml.rb
@@ -3,23 +3,23 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/node'
-require 'puppet/indirector/yaml/node'
+require 'puppet/indirector/node/yaml'
-describe Puppet::Indirector::Yaml::Node do
+describe Puppet::Node::Yaml do
it "should be a subclass of the Yaml terminus" do
- Puppet::Indirector::Yaml::Node.superclass.should equal(Puppet::Indirector::Yaml)
+ Puppet::Node::Yaml.superclass.should equal(Puppet::Indirector::Yaml)
end
it "should have documentation" do
- Puppet::Indirector::Yaml::Node.doc.should_not be_nil
+ Puppet::Node::Yaml.doc.should_not be_nil
end
it "should be registered with the configuration store indirection" do
indirection = Puppet::Indirector::Indirection.instance(:node)
- Puppet::Indirector::Yaml::Node.indirection.should equal(indirection)
+ Puppet::Node::Yaml.indirection.should equal(indirection)
end
it "should have its name set to :node" do
- Puppet::Indirector::Yaml::Node.name.should == :node
+ Puppet::Node::Yaml.name.should == :yaml
end
end
diff --git a/spec/unit/indirector/null.rb b/spec/unit/indirector/null.rb
index 9e1dcb07c..fe3a382dc 100755
--- a/spec/unit/indirector/null.rb
+++ b/spec/unit/indirector/null.rb
@@ -12,7 +12,7 @@ describe Puppet::Indirector::Null do
@null_class = Class.new(Puppet::Indirector::Null) do
def self.to_s
- "Testing"
+ "Mystuff::Testing"
end
end
diff --git a/spec/unit/indirector/code/report.rb b/spec/unit/indirector/report/processor.rb
index a27eaa297..587f512ee 100755
--- a/spec/unit/indirector/code/report.rb
+++ b/spec/unit/indirector/report/processor.rb
@@ -5,19 +5,19 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
-require 'puppet/indirector/code/report'
+require 'puppet/indirector/report/processor'
-describe Puppet::Indirector::Code::Report do
+describe Puppet::Transaction::Report::Processor do
it "should provide a method for saving reports" do
- Puppet::Indirector::Code::Report.new.should respond_to(:save)
+ Puppet::Transaction::Report::Processor.new.should respond_to(:save)
end
end
-describe Puppet::Indirector::Code::Report, " when saving a report" do
+describe Puppet::Transaction::Report::Processor, " when saving a report" do
before do
Puppet.settings.stubs(:use)
- @reporter = Puppet::Indirector::Code::Report.new
+ @reporter = Puppet::Transaction::Report::Processor.new
end
it "should not process the report if reports are set to 'none'" do
@@ -33,11 +33,11 @@ describe Puppet::Indirector::Code::Report, " when saving a report" do
end
end
-describe Puppet::Indirector::Code::Report, " when processing a report" do
+describe Puppet::Transaction::Report::Processor, " when processing a report" do
before do
Puppet.settings.stubs(:value).with(:reports).returns("one")
Puppet.settings.stubs(:use)
- @reporter = Puppet::Indirector::Code::Report.new
+ @reporter = Puppet::Transaction::Report::Processor.new
@report_type = mock 'one'
@dup_report = mock 'dupe report'
diff --git a/spec/unit/indirector/rest/node.rb b/spec/unit/indirector/rest/node.rb
deleted file mode 100755
index c78556ada..000000000
--- a/spec/unit/indirector/rest/node.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
-
-require 'puppet/indirector/rest/node'
-
-describe Puppet::Indirector::REST::Node do
- before do
- @searcher = Puppet::Indirector::REST::Node.new
- end
-
-
-end
diff --git a/spec/unit/indirector/terminus.rb b/spec/unit/indirector/terminus.rb
index 3361bfeeb..99193dbc3 100755
--- a/spec/unit/indirector/terminus.rb
+++ b/spec/unit/indirector/terminus.rb
@@ -3,65 +3,70 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/defaults'
require 'puppet/indirector'
+require 'puppet/indirector/file'
-describe Puppet::Indirector::Terminus do
- before do
+module TerminusInstanceTesting
+ def setup
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
-
@indirection = stub 'indirection', :name => :my_stuff, :register_terminus_type => nil
Puppet::Indirector::Indirection.stubs(:instance).with(:my_stuff).returns(@indirection)
@abstract_terminus = Class.new(Puppet::Indirector::Terminus) do
def self.to_s
- "Abstract"
+ "Testing::Abstract"
end
end
- @terminus = Class.new(@abstract_terminus) do
+ @terminus_class = Class.new(@abstract_terminus) do
def self.to_s
- "Terminus::Type::MyStuff"
+ "MyStuff::TermType"
end
end
+ @terminus = @terminus_class.new
end
+end
+
+describe Puppet::Indirector::Terminus do
+ include TerminusInstanceTesting
it "should provide a method for setting terminus class documentation" do
- @terminus.should respond_to(:desc)
+ @terminus_class.should respond_to(:desc)
end
it "should support a class-level name attribute" do
- @terminus.should respond_to(:name)
+ @terminus_class.should respond_to(:name)
end
it "should support a class-level indirection attribute" do
- @terminus.should respond_to(:indirection)
+ @terminus_class.should respond_to(:indirection)
end
it "should support a class-level terminus-type attribute" do
- @terminus.should respond_to(:terminus_type)
+ @terminus_class.should respond_to(:terminus_type)
end
it "should support a class-level model attribute" do
- @terminus.should respond_to(:model)
+ @terminus_class.should respond_to(:model)
end
it "should accept indirection instances as its indirection" do
indirection = stub 'indirection', :is_a? => true, :register_terminus_type => nil
- proc { @terminus.indirection = indirection }.should_not raise_error
- @terminus.indirection.should equal(indirection)
+ proc { @terminus_class.indirection = indirection }.should_not raise_error
+ @terminus_class.indirection.should equal(indirection)
end
it "should look up indirection instances when only a name has been provided" do
indirection = mock 'indirection'
Puppet::Indirector::Indirection.expects(:instance).with(:myind).returns(indirection)
- @terminus.indirection = :myind
- @terminus.indirection.should equal(indirection)
+ @terminus_class.indirection = :myind
+ @terminus_class.indirection.should equal(indirection)
end
it "should fail when provided a name that does not resolve to an indirection" do
Puppet::Indirector::Indirection.expects(:instance).with(:myind).returns(nil)
- proc { @terminus.indirection = :myind }.should raise_error(ArgumentError)
+ proc { @terminus_class.indirection = :myind }.should raise_error(ArgumentError)
# It shouldn't overwrite our existing one (or, more normally, it shouldn't set
# anything).
- @terminus.indirection.should equal(@indirection)
+ @terminus_class.indirection.should equal(@indirection)
end
end
@@ -75,9 +80,9 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do
end
it "should provide a method for returning terminus classes by name and type" do
- terminus = stub 'terminus_type', :terminus_type => :abstract, :name => :whatever
+ terminus = stub 'terminus_type', :name => :abstract, :indirection_name => :whatever
Puppet::Indirector::Terminus.register_terminus_class(terminus)
- Puppet::Indirector::Terminus.terminus_class(:abstract, :whatever).should equal(terminus)
+ Puppet::Indirector::Terminus.terminus_class(:whatever, :abstract).should equal(terminus)
end
it "should set up autoloading for any terminus class types requested" do
@@ -88,6 +93,7 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do
it "should load terminus classes that are not found" do
# Set up instance loading; it would normally happen automatically
Puppet::Indirector::Terminus.instance_load :test1, "puppet/indirector/test1"
+
Puppet::Indirector::Terminus.instance_loader(:test1).expects(:load).with(:yay)
Puppet::Indirector::Terminus.terminus_class(:test1, :yay)
end
@@ -103,7 +109,7 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do
proc {
@terminus = Class.new(@abstract_terminus) do
def self.to_s
- "MyIndirection"
+ "MyIndirection::TestType"
end
end
}.should raise_error(ArgumentError)
@@ -111,9 +117,9 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do
it "should register the terminus class with the terminus base class" do
Puppet::Indirector::Terminus.expects(:register_terminus_class).with do |type|
- type.terminus_type == :abstract and type.name == :my_indirection
+ type.indirection_name == :my_indirection and type.name == :test_terminus
end
- @indirection = stub 'indirection', :name => :myind, :register_terminus_type => nil
+ @indirection = stub 'indirection', :name => :my_indirection, :register_terminus_type => nil
Puppet::Indirector::Indirection.expects(:instance).with(:my_indirection).returns(@indirection)
@abstract_terminus = Class.new(Puppet::Indirector::Terminus) do
@@ -124,21 +130,55 @@ describe Puppet::Indirector::Terminus, " when managing terminus classes" do
@terminus = Class.new(@abstract_terminus) do
def self.to_s
- "MyIndirection"
+ "MyIndirection::TestTerminus"
end
end
end
end
-describe Puppet::Indirector::Terminus, " when converting class constants to indirection names" do
- it "should convert camel case to lower case with underscores as word separators" do
- subclass = mock 'subclass'
- subclass.stubs(:to_s).returns("OneTwo")
- subclass.stubs(:mark_as_abstract_terminus)
+describe Puppet::Indirector::Terminus, " when parsing class constants for indirection and terminus names" do
+ before do
+ @subclass = mock 'subclass'
+ @subclass.stubs(:to_s).returns("TestInd::OneTwo")
+ @subclass.stubs(:mark_as_abstract_terminus)
+ Puppet::Indirector::Terminus.stubs(:register_terminus_class)
+ end
+
+ it "should fail when anonymous classes are used" do
+ proc { Puppet::Indirector::Terminus.inherited(Class.new) }.should raise_error(Puppet::DevError)
+ end
+
+ it "should use the last term in the constant for the terminus class name" do
+ @subclass.expects(:name=).with(:one_two)
+ @subclass.stubs(:indirection=)
+ Puppet::Indirector::Terminus.inherited(@subclass)
+ end
+
+ it "should convert the terminus name to a downcased symbol" do
+ @subclass.expects(:name=).with(:one_two)
+ @subclass.stubs(:indirection=)
+ Puppet::Indirector::Terminus.inherited(@subclass)
+ end
+
+ it "should use the second to last term in the constant for the indirection name" do
+ @subclass.expects(:indirection=).with(:test_ind)
+ @subclass.stubs(:name=)
+ @subclass.stubs(:terminus_type=)
+ Puppet::Indirector::File.inherited(@subclass)
+ end
+
+ it "should convert the indirection name to a downcased symbol" do
+ @subclass.expects(:indirection=).with(:test_ind)
+ @subclass.stubs(:name=)
+ @subclass.stubs(:terminus_type=)
+ Puppet::Indirector::File.inherited(@subclass)
+ end
- subclass.expects(:name=).with(:one_two)
+ it "should convert camel case to lower case with underscores as word separators" do
+ @subclass.expects(:name=).with(:one_two)
+ @subclass.stubs(:indirection=)
- Puppet::Indirector::Terminus.inherited(subclass)
+ Puppet::Indirector::Terminus.inherited(@subclass)
end
end
@@ -166,24 +206,7 @@ describe Puppet::Indirector::Terminus, " when creating terminus class types" do
end
describe Puppet::Indirector::Terminus, " when creating terminus classes" do
- before do
- Puppet::Indirector::Terminus.stubs(:register_terminus_class)
-
- @indirection = stub 'indirection', :name => :myind, :register_terminus_type => nil
- Puppet::Indirector::Indirection.expects(:instance).with(:my_indirection).returns(@indirection)
-
- @abstract_terminus = Class.new(Puppet::Indirector::Terminus) do
- def self.to_s
- "Abstract"
- end
- end
- @terminus = Class.new(@abstract_terminus) do
- def self.to_s
- "MyIndirection"
- end
- end
- end
-
+ include TerminusInstanceTesting
it "should associate the subclass with an indirection based on the subclass constant" do
@terminus.indirection.should equal(@indirection)
end
@@ -193,7 +216,7 @@ describe Puppet::Indirector::Terminus, " when creating terminus classes" do
end
it "should set the subclass's name to the indirection name" do
- @terminus.name.should == :my_indirection
+ @terminus.name.should == :term_type
end
it "should set the subclass's model to the indirection model" do
@@ -202,31 +225,11 @@ describe Puppet::Indirector::Terminus, " when creating terminus classes" do
end
end
-module TerminusInstanceTesting
- def setup
- Puppet::Indirector::Terminus.stubs(:register_terminus_class)
- @indirection = stub 'indirection', :name => :myyaml, :register_terminus_type => nil
- Puppet::Indirector::Indirection.stubs(:instance).with(:my_stuff).returns(@indirection)
- @abstract_terminus = Class.new(Puppet::Indirector::Terminus) do
- def self.to_s
- "Abstract"
- end
- end
- @terminus_class = Class.new(@abstract_terminus) do
- def self.to_s
- "MyStuff"
- end
- end
- @terminus_class.name = :test
- @terminus = @terminus_class.new
- end
-end
-
describe Puppet::Indirector::Terminus, " when a terminus instance" do
include TerminusInstanceTesting
it "should return the class's name as its name" do
- @terminus.name.should == :test
+ @terminus.name.should == :term_type
end
it "should return the class's indirection as its indirection" do
diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb
index 453b703a1..f217a31b5 100755
--- a/spec/unit/indirector/yaml.rb
+++ b/spec/unit/indirector/yaml.rb
@@ -10,7 +10,7 @@ module YamlTesting
Puppet::Indirector::Indirection.stubs(:instance).with(:my_yaml).returns(@indirection)
@store_class = Class.new(Puppet::Indirector::Yaml) do
def self.to_s
- "MyYaml"
+ "MyYaml::MyType"
end
end
@store = @store_class.new
diff --git a/spec/unit/indirector/yaml/configuration.rb b/spec/unit/indirector/yaml/configuration.rb
deleted file mode 100755
index 3f0bc6f30..000000000
--- a/spec/unit/indirector/yaml/configuration.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env ruby
-
-require File.dirname(__FILE__) + '/../../../spec_helper'
-
-require 'puppet/node/configuration'
-require 'puppet/indirector/yaml/configuration'
-
-describe Puppet::Indirector::Yaml::Configuration do
- it "should be a subclass of the Yaml terminus" do
- Puppet::Indirector::Yaml::Configuration.superclass.should equal(Puppet::Indirector::Yaml)
- end
-
- it "should have documentation" do
- Puppet::Indirector::Yaml::Configuration.doc.should_not be_nil
- end
-
- it "should be registered with the configuration store indirection" do
- indirection = Puppet::Indirector::Indirection.instance(:configuration)
- Puppet::Indirector::Yaml::Configuration.indirection.should equal(indirection)
- end
-
- it "should have its name set to :configuration" do
- Puppet::Indirector::Yaml::Configuration.name.should == :configuration
- end
-end