summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2008-02-18 10:57:40 -0600
committerRick Bradley <rick@rickbradley.com>2008-02-18 10:57:40 -0600
commitaa14ce7544300ba15f95f2f03d89ff3d8a0afe9d (patch)
tree3d5a2b4054edca89cf3199e143b1478392025781 /spec
parentcfbb9cf7b44cb48433b118108e36660e3e6815bb (diff)
downloadpuppet-aa14ce7544300ba15f95f2f03d89ff3d8a0afe9d.tar.gz
puppet-aa14ce7544300ba15f95f2f03d89ff3d8a0afe9d.tar.xz
puppet-aa14ce7544300ba15f95f2f03d89ff3d8a0afe9d.zip
moving setup() methods to before :each, so that the tests will run with rspec, as opposed to just rake (which calls them directly with ruby, as opposed to any spec binary)
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/indirector/file_server.rb223
1 files changed, 109 insertions, 114 deletions
diff --git a/spec/unit/indirector/file_server.rb b/spec/unit/indirector/file_server.rb
index fda60f1ec..974b95e0e 100755
--- a/spec/unit/indirector/file_server.rb
+++ b/spec/unit/indirector/file_server.rb
@@ -8,8 +8,9 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/indirector/file_server'
require 'puppet/file_serving/configuration'
-module FileServerTerminusTesting
- def setup
+describe Puppet::Indirector::FileServer do
+
+ before :each do
Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@model = mock 'model'
@indirection = stub 'indirection', :name => :mystuff, :register_terminus_type => nil, :model => @model
@@ -27,147 +28,141 @@ module FileServerTerminusTesting
@configuration = mock 'configuration'
Puppet::FileServing::Configuration.stubs(:create).returns(@configuration)
end
-end
-describe Puppet::Indirector::FileServer, " when finding files" do
- include FileServerTerminusTesting
+ describe Puppet::Indirector::FileServer, " when finding files" do
- it "should use the path portion of the URI as the file name" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.find(@uri)
- end
+ it "should use the path portion of the URI as the file name" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil)
+ @file_server.find(@uri)
+ end
- it "should use the FileServing configuration to convert the file name to a fully qualified path" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.find(@uri)
- end
+ it "should use the FileServing configuration to convert the file name to a fully qualified path" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil)
+ @file_server.find(@uri)
+ end
- it "should pass the node name to the FileServing configuration if one is provided" do
- @configuration.expects(:file_path).with("/my/local/file", :node => "testing")
- @file_server.find(@uri, :node => "testing")
- end
+ it "should pass the node name to the FileServing configuration if one is provided" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => "testing")
+ @file_server.find(@uri, :node => "testing")
+ end
- it "should return nil if no fully qualified path is found" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil)
- @file_server.find(@uri).should be_nil
- end
+ it "should return nil if no fully qualified path is found" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil)
+ @file_server.find(@uri).should be_nil
+ end
- it "should return an instance of the model created with the full path if a file is found" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file")
- @model.expects(:new).returns(:myinstance)
- @file_server.find(@uri).should == :myinstance
+ it "should return an instance of the model created with the full path if a file is found" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file")
+ @model.expects(:new).returns(:myinstance)
+ @file_server.find(@uri).should == :myinstance
+ end
end
-end
+ describe Puppet::Indirector::FileServer, " when returning instances" do
+ before :each do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file")
+ @instance = mock 'instance'
+ end
-describe Puppet::Indirector::FileServer, " when returning instances" do
- include FileServerTerminusTesting
-
- before do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file")
- @instance = mock 'instance'
- end
-
- it "should create the instance with the key used to find the instance" do
- @model.expects(:new).with { |key, *options| key == @uri }
- @file_server.find(@uri)
- end
+ it "should create the instance with the key used to find the instance" do
+ @model.expects(:new).with { |key, *options| key == @uri }
+ @file_server.find(@uri)
+ end
- it "should create the instance with the path at which the instance was found" do
- @model.expects(:new).with { |key, options| options[:path] == "/some/file" }
- @file_server.find(@uri)
- end
+ it "should create the instance with the path at which the instance was found" do
+ @model.expects(:new).with { |key, options| options[:path] == "/some/file" }
+ @file_server.find(@uri)
+ end
- it "should set the provided :links setting on to the instance if one is provided" do
- @model.expects(:new).returns(@instance)
- @instance.expects(:links=).with(:mytest)
- @file_server.find(@uri, :links => :mytest)
- end
+ it "should set the provided :links setting on to the instance if one is provided" do
+ @model.expects(:new).returns(@instance)
+ @instance.expects(:links=).with(:mytest)
+ @file_server.find(@uri, :links => :mytest)
+ end
- it "should not set a :links value if no :links parameter is provided" do
- @model.expects(:new).returns(@instance)
- @file_server.find(@uri)
+ it "should not set a :links value if no :links parameter is provided" do
+ @model.expects(:new).returns(@instance)
+ @file_server.find(@uri)
+ end
end
-end
-describe Puppet::Indirector::FileServer, " when checking authorization" do
- include FileServerTerminusTesting
+ describe Puppet::Indirector::FileServer, " when checking authorization" do
- it "should have an authorization hook" do
- @file_server.should respond_to(:authorized?)
- end
+ it "should have an authorization hook" do
+ @file_server.should respond_to(:authorized?)
+ end
- it "should deny the :destroy method" do
- @file_server.authorized?(:destroy, "whatever").should be_false
- end
+ it "should deny the :destroy method" do
+ @file_server.authorized?(:destroy, "whatever").should be_false
+ end
- it "should deny the :save method" do
- @file_server.authorized?(:save, "whatever").should be_false
- end
+ it "should deny the :save method" do
+ @file_server.authorized?(:save, "whatever").should be_false
+ end
- it "should use the file server configuration to determine authorization" do
- @configuration.expects(:authorized?)
- @file_server.authorized?(:find, "puppetmounts://host/my/file")
- end
+ it "should use the file server configuration to determine authorization" do
+ @configuration.expects(:authorized?)
+ @file_server.authorized?(:find, "puppetmounts://host/my/file")
+ end
- it "should pass the file path from the URI to the file server configuration" do
- @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" }
- @file_server.authorized?(:find, "puppetmounts://host/my/file")
- end
+ it "should pass the file path from the URI to the file server configuration" do
+ @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" }
+ @file_server.authorized?(:find, "puppetmounts://host/my/file")
+ end
- it "should pass the node name to the file server configuration" do
- @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" }
- @file_server.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode")
- end
+ it "should pass the node name to the file server configuration" do
+ @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" }
+ @file_server.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode")
+ end
- it "should pass the IP address to the file server configuration" do
- @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" }
- @file_server.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip")
- end
+ it "should pass the IP address to the file server configuration" do
+ @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" }
+ @file_server.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip")
+ end
- it "should return false if the file server configuration denies authorization" do
- @configuration.expects(:authorized?).returns(false)
- @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_false
- end
+ it "should return false if the file server configuration denies authorization" do
+ @configuration.expects(:authorized?).returns(false)
+ @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_false
+ end
- it "should return true if the file server configuration approves authorization" do
- @configuration.expects(:authorized?).returns(true)
- @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_true
+ it "should return true if the file server configuration approves authorization" do
+ @configuration.expects(:authorized?).returns(true)
+ @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_true
+ end
end
-end
-describe Puppet::Indirector::FileServer, " when searching for files" do
- include FileServerTerminusTesting
+ describe Puppet::Indirector::FileServer, " when searching for files" do
- it "should use the path portion of the URI as the file name" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.search(@uri)
- end
+ it "should use the path portion of the URI as the file name" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil)
+ @file_server.search(@uri)
+ end
- it "should use the FileServing configuration to convert the file name to a fully qualified path" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil)
- @file_server.search(@uri)
- end
+ it "should use the FileServing configuration to convert the file name to a fully qualified path" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil)
+ @file_server.search(@uri)
+ end
- it "should pass the node name to the FileServing configuration if one is provided" do
- @configuration.expects(:file_path).with("/my/local/file", :node => "testing")
- @file_server.search(@uri, :node => "testing")
- end
+ it "should pass the node name to the FileServing configuration if one is provided" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => "testing")
+ @file_server.search(@uri, :node => "testing")
+ end
- it "should return nil if no fully qualified path is found" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil)
- @file_server.search(@uri).should be_nil
- end
+ it "should return nil if no fully qualified path is found" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil)
+ @file_server.search(@uri).should be_nil
+ end
- it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file")
- @file_server.expects(:path2instances).with(@uri, "/my/file", {})
- @file_server.search(@uri)
- end
+ it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file")
+ @file_server.expects(:path2instances).with(@uri, "/my/file", {})
+ @file_server.search(@uri)
+ end
- it "should pass any options on to :path2instances" do
- @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file")
- @file_server.expects(:path2instances).with(@uri, "/my/file", :testing => :one, :other => :two)
- @file_server.search(@uri, :testing => :one, :other => :two)
+ it "should pass any options on to :path2instances" do
+ @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file")
+ @file_server.expects(:path2instances).with(@uri, "/my/file", :testing => :one, :other => :two)
+ @file_server.search(@uri, :testing => :one, :other => :two)
+ end
end
-end
+end \ No newline at end of file