summaryrefslogtreecommitdiffstats
path: root/spec/unit/node
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-20 15:24:20 -0500
committerLuke Kanies <luke@madstop.com>2007-09-20 15:24:20 -0500
commit8212f88ce3ad2ddbc7e1e713111d9478171c42b8 (patch)
tree5c61cfd3ca2b76d9ab093feeee89c351796667e0 /spec/unit/node
parent4cde0344b50084b897792ba4cdd1f62a733d7f53 (diff)
downloadpuppet-8212f88ce3ad2ddbc7e1e713111d9478171c42b8.tar.gz
puppet-8212f88ce3ad2ddbc7e1e713111d9478171c42b8.tar.xz
puppet-8212f88ce3ad2ddbc7e1e713111d9478171c42b8.zip
Fixing all existing spec tests so that they now
pass given the redesign that Rick implemented. This was mostly a question of fixing the method names and the mocks.
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-xspec/unit/node/facts.rb11
-rwxr-xr-xspec/unit/node/node.rb8
-rwxr-xr-xspec/unit/node/searching.rb16
3 files changed, 18 insertions, 17 deletions
diff --git a/spec/unit/node/facts.rb b/spec/unit/node/facts.rb
index c677c1d2e..61f05a2b2 100755
--- a/spec/unit/node/facts.rb
+++ b/spec/unit/node/facts.rb
@@ -7,21 +7,22 @@ require 'puppet/node/facts'
describe Puppet::Node::Facts, " when indirecting" do
before do
@terminus = mock 'terminus'
- Puppet::Indirector.terminus(:facts, Puppet[:fact_store].intern).stubs(:new).returns(@terminus)
+ Puppet::Node::Facts.stubs(:indirection).returns(@terminus)
# We have to clear the cache so that the facts ask for our terminus stub,
# instead of anything that might be cached.
Puppet::Indirector::Indirection.clear_cache
+ @facts = Puppet::Node::Facts.new("me", "one" => "two")
end
it "should redirect to the specified fact store for retrieval" do
- @terminus.expects(:get).with(:my_facts)
- Puppet::Node::Facts.get(:my_facts)
+ @terminus.expects(:find).with(:my_facts)
+ Puppet::Node::Facts.find(:my_facts)
end
it "should redirect to the specified fact store for storage" do
- @terminus.expects(:post).with(:my_facts)
- Puppet::Node::Facts.post(:my_facts)
+ @terminus.expects(:save).with(@facts)
+ @facts.save
end
after do
diff --git a/spec/unit/node/node.rb b/spec/unit/node/node.rb
index 9342dc5ce..899d81ac7 100755
--- a/spec/unit/node/node.rb
+++ b/spec/unit/node/node.rb
@@ -85,7 +85,7 @@ end
describe Puppet::Node, " when merging facts" do
before do
@node = Puppet::Node.new("testnode")
- Puppet::Node::Facts.stubs(:get).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b"))
+ Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b"))
end
it "should prefer parameters already set on the node over facts from the node" do
@@ -110,12 +110,12 @@ end
describe Puppet::Node, " when indirecting" do
before do
@terminus = mock 'terminus'
- Puppet::Indirector.terminus(:node, Puppet[:node_source]).stubs(:new).returns(@terminus)
+ Puppet::Node.stubs(:indirection).returns(@terminus)
end
it "should redirect to the specified node source" do
- @terminus.expects(:get).with(:my_node)
- Puppet::Node.get(:my_node)
+ @terminus.expects(:find).with(:my_node.to_s)
+ Puppet::Node.find(:my_node.to_s)
end
after do
diff --git a/spec/unit/node/searching.rb b/spec/unit/node/searching.rb
index 553822576..b7105050a 100755
--- a/spec/unit/node/searching.rb
+++ b/spec/unit/node/searching.rb
@@ -10,12 +10,12 @@ describe Puppet::Node::Searching, " when searching for nodes" do
@searcher.extend(Puppet::Node::Searching)
@facts = Puppet::Node::Facts.new("foo", "hostname" => "yay", "domain" => "domain.com")
@node = Puppet::Node.new("foo")
- Puppet::Node::Facts.stubs(:get).with("foo").returns(@facts)
+ Puppet::Node::Facts.stubs(:find).with("foo").returns(@facts)
end
it "should search for the node by its key first" do
names = []
- @searcher.expects(:get).with do |name|
+ @searcher.expects(:find).with do |name|
names << name
names == %w{foo}
end.returns(@node)
@@ -24,15 +24,15 @@ describe Puppet::Node::Searching, " when searching for nodes" do
it "should return the first node found using the generated list of names" do
names = []
- @searcher.expects(:get).with("foo").returns(nil)
- @searcher.expects(:get).with("yay.domain.com").returns(@node)
+ @searcher.expects(:find).with("foo").returns(nil)
+ @searcher.expects(:find).with("yay.domain.com").returns(@node)
@searcher.search("foo").should equal(@node)
end
it "should search for the rest of the names inversely by length" do
names = []
@facts.values["fqdn"] = "longer.than.the.normal.fqdn.com"
- @searcher.stubs(:get).with do |name|
+ @searcher.stubs(:find).with do |name|
names << name
end
@searcher.search("foo")
@@ -51,7 +51,7 @@ describe Puppet::Node::Searching, " when searching for nodes" do
it "should attempt to find a default node if no names are found" do
names = []
- @searcher.stubs(:get).with do |name|
+ @searcher.stubs(:find).with do |name|
names << name
end.returns(nil)
@searcher.search("foo")
@@ -59,7 +59,7 @@ describe Puppet::Node::Searching, " when searching for nodes" do
end
it "should cache the nodes" do
- @searcher.expects(:get).with("foo").returns(@node)
+ @searcher.expects(:find).with("foo").returns(@node)
@searcher.search("foo").should equal(@node)
@searcher.search("foo").should equal(@node)
end
@@ -68,7 +68,7 @@ describe Puppet::Node::Searching, " when searching for nodes" do
node2 = Puppet::Node.new("foo2")
Puppet[:filetimeout] = -1
# I couldn't get this to work with :expects
- @searcher.stubs(:get).returns(@node, node2).then.raises(ArgumentError)
+ @searcher.stubs(:find).returns(@node, node2).then.raises(ArgumentError)
@searcher.search("foo").should equal(@node)
@searcher.search("foo").should equal(node2)
end