From 14f8160674628340ccfd79baeb84f66cf1e0398a Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Mon, 29 Nov 2010 11:55:00 -0800 Subject: Maint: Refactor tests to use .indirection. Replaced uses of the find, search, destroy, and expire methods on model classes with direct calls to the indirection objects. This change affects tests only. --- spec/integration/node_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'spec/integration/node_spec.rb') diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb index c635e7f32..0d46259dd 100755 --- a/spec/integration/node_spec.rb +++ b/spec/integration/node_spec.rb @@ -24,7 +24,7 @@ describe Puppet::Node do terminus.expects(:translate).with(@name, "myresults").returns "translated_results" terminus.expects(:create_node).with(@name, "translated_results").returns @node - Puppet::Node.find(@name).should equal(@node) + Puppet::Node.indirection.find(@name).should equal(@node) end it "should be able to use the yaml terminus" do @@ -36,7 +36,7 @@ describe Puppet::Node do terminus.expects(:path).with(@name).returns "/my/yaml/file" FileTest.expects(:exist?).with("/my/yaml/file").returns false - Puppet::Node.find(@name).should be_nil + Puppet::Node.indirection.find(@name).should be_nil end it "should have an ldap terminus" do @@ -51,7 +51,7 @@ describe Puppet::Node do Puppet::Node.expects(:new).with(@name).returns @node - Puppet::Node.find(@name).should equal(@node) + Puppet::Node.indirection.find(@name).should equal(@node) end describe "and using the memory terminus" do @@ -64,29 +64,29 @@ describe Puppet::Node do end it "should find no nodes by default" do - Puppet::Node.find(@name).should be_nil + Puppet::Node.indirection.find(@name).should be_nil end it "should be able to find nodes that were previously saved" do @node.save - Puppet::Node.find(@name).should equal(@node) + Puppet::Node.indirection.find(@name).should equal(@node) end it "should replace existing saved nodes when a new node with the same name is saved" do @node.save two = Puppet::Node.new(@name) two.save - Puppet::Node.find(@name).should equal(two) + Puppet::Node.indirection.find(@name).should equal(two) end it "should be able to remove previously saved nodes" do @node.save - Puppet::Node.destroy(@node.name) - Puppet::Node.find(@name).should be_nil + Puppet::Node.indirection.destroy(@node.name) + Puppet::Node.indirection.find(@name).should be_nil end it "should fail when asked to destroy a node that does not exist" do - proc { Puppet::Node.destroy(@node) }.should raise_error(ArgumentError) + proc { Puppet::Node.indirection.destroy(@node) }.should raise_error(ArgumentError) end end end -- cgit From f77764de3ace7cc880a77466618a5affe1b61a8e Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 30 Nov 2010 12:06:33 -0800 Subject: Maint: Modified tests of indirector.save to call the indirection directly. This change replaces calls to .save with calls to .indirection.save(). This makes the use of the indirector explicit rather than implicit so that it will be easier to search for all indirector call sites using grep. This is an intermediate refactor on the way towards allowing indirector calls to be explicitly routed to multiple termini. This patch affects tests only; the next patch will make the corresponding change to the code. --- spec/integration/node_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/integration/node_spec.rb') diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb index 0d46259dd..911a423a0 100755 --- a/spec/integration/node_spec.rb +++ b/spec/integration/node_spec.rb @@ -68,19 +68,19 @@ describe Puppet::Node do end it "should be able to find nodes that were previously saved" do - @node.save + Puppet::Node.indirection.save(@node) Puppet::Node.indirection.find(@name).should equal(@node) end it "should replace existing saved nodes when a new node with the same name is saved" do - @node.save + Puppet::Node.indirection.save(@node) two = Puppet::Node.new(@name) - two.save + Puppet::Node.indirection.save(two) Puppet::Node.indirection.find(@name).should equal(two) end it "should be able to remove previously saved nodes" do - @node.save + Puppet::Node.indirection.save(@node) Puppet::Node.indirection.destroy(@node.name) Puppet::Node.indirection.find(@name).should be_nil end -- cgit From 626d7564467bdc0e9d2d385e9aa10c539d9ed175 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Mon, 6 Dec 2010 12:01:18 -0800 Subject: maint: Use expand_path when requiring spec_helper or puppettest Doing a require to a relative path can cause files to be required more than once when they're required from different relative paths. If you expand the path fully, this won't happen. Ruby 1.9 also requires that you use expand_path when doing these requires. Paired-with: Jesse Wolfe --- spec/integration/node_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/integration/node_spec.rb') diff --git a/spec/integration/node_spec.rb b/spec/integration/node_spec.rb index 911a423a0..4c8a2c2b1 100755 --- a/spec/integration/node_spec.rb +++ b/spec/integration/node_spec.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2007-9-23. # Copyright (c) 2007. All rights reserved. -require File.dirname(__FILE__) + '/../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'puppet/node' -- cgit