summaryrefslogtreecommitdiffstats
path: root/spec/unit/file_serving/mount
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /spec/unit/file_serving/mount
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
Diffstat (limited to 'spec/unit/file_serving/mount')
-rwxr-xr-xspec/unit/file_serving/mount/file_spec.rb342
-rwxr-xr-xspec/unit/file_serving/mount/modules_spec.rb86
-rwxr-xr-xspec/unit/file_serving/mount/plugins_spec.rb78
3 files changed, 253 insertions, 253 deletions
diff --git a/spec/unit/file_serving/mount/file_spec.rb b/spec/unit/file_serving/mount/file_spec.rb
index e77523fd5..56b4f54f1 100755
--- a/spec/unit/file_serving/mount/file_spec.rb
+++ b/spec/unit/file_serving/mount/file_spec.rb
@@ -4,193 +4,193 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/file_serving/mount/file'
module FileServingMountTesting
- def stub_facter(hostname)
- Facter.stubs(:value).with("hostname").returns(hostname.sub(/\..+/, ''))
- Facter.stubs(:value).with("domain").returns(hostname.sub(/^[^.]+\./, ''))
- end
+ def stub_facter(hostname)
+ Facter.stubs(:value).with("hostname").returns(hostname.sub(/\..+/, ''))
+ Facter.stubs(:value).with("domain").returns(hostname.sub(/^[^.]+\./, ''))
+ end
end
describe Puppet::FileServing::Mount::File do
- it "should provide a method for clearing its cached host information" do
- old = Puppet::FileServing::Mount::File.localmap
- Puppet::Util::Cacher.expire
- Puppet::FileServing::Mount::File.localmap.should_not equal(old)
- end
-
- it "should be invalid if it does not have a path" do
- lambda { Puppet::FileServing::Mount::File.new("foo").validate }.should raise_error(ArgumentError)
- end
-
- it "should be valid if it has a path" do
- FileTest.stubs(:directory?).returns true
- FileTest.stubs(:readable?).returns true
- mount = Puppet::FileServing::Mount::File.new("foo")
- mount.path = "/foo"
- lambda { mount.validate }.should_not raise_error(ArgumentError)
- end
+ it "should provide a method for clearing its cached host information" do
+ old = Puppet::FileServing::Mount::File.localmap
+ Puppet::Util::Cacher.expire
+ Puppet::FileServing::Mount::File.localmap.should_not equal(old)
+ end
+
+ it "should be invalid if it does not have a path" do
+ lambda { Puppet::FileServing::Mount::File.new("foo").validate }.should raise_error(ArgumentError)
+ end
+
+ it "should be valid if it has a path" do
+ FileTest.stubs(:directory?).returns true
+ FileTest.stubs(:readable?).returns true
+ mount = Puppet::FileServing::Mount::File.new("foo")
+ mount.path = "/foo"
+ lambda { mount.validate }.should_not raise_error(ArgumentError)
+ end
end
describe Puppet::FileServing::Mount::File, " when setting the path" do
- before do
- @mount = Puppet::FileServing::Mount::File.new("test")
- @dir = "/this/path/does/not/exist"
- end
-
- it "should fail if the path is not a directory" do
- FileTest.expects(:directory?).returns(false)
- proc { @mount.path = @dir }.should raise_error(ArgumentError)
- end
-
- it "should fail if the path is not readable" do
- FileTest.expects(:directory?).returns(true)
- FileTest.expects(:readable?).returns(false)
- proc { @mount.path = @dir }.should raise_error(ArgumentError)
- end
+ before do
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @dir = "/this/path/does/not/exist"
+ end
+
+ it "should fail if the path is not a directory" do
+ FileTest.expects(:directory?).returns(false)
+ proc { @mount.path = @dir }.should raise_error(ArgumentError)
+ end
+
+ it "should fail if the path is not readable" do
+ FileTest.expects(:directory?).returns(true)
+ FileTest.expects(:readable?).returns(false)
+ proc { @mount.path = @dir }.should raise_error(ArgumentError)
+ end
end
describe Puppet::FileServing::Mount::File, " when substituting hostnames and ip addresses into file paths" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @host = "host.domain.com"
- end
-
- it "should replace incidences of %h in the path with the client's short name" do
- @mount.path = "/dir/%h/yay"
- @mount.path(@host).should == "/dir/host/yay"
- end
-
- it "should replace incidences of %H in the path with the client's fully qualified name" do
- @mount.path = "/dir/%H/yay"
- @mount.path(@host).should == "/dir/host.domain.com/yay"
- end
-
- it "should replace incidences of %d in the path with the client's domain name" do
- @mount.path = "/dir/%d/yay"
- @mount.path(@host).should == "/dir/domain.com/yay"
- end
-
- it "should perform all necessary replacements" do
- @mount.path = "/%h/%d/%H"
- @mount.path(@host).should == "/host/domain.com/host.domain.com"
- end
-
- it "should use local host information if no client data is provided" do
- stub_facter("myhost.mydomain.com")
- @mount.path = "/%h/%d/%H"
- @mount.path.should == "/myhost/mydomain.com/myhost.mydomain.com"
- end
-
- after do
- Puppet::Util::Cacher.expire
- end
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @host = "host.domain.com"
+ end
+
+ it "should replace incidences of %h in the path with the client's short name" do
+ @mount.path = "/dir/%h/yay"
+ @mount.path(@host).should == "/dir/host/yay"
+ end
+
+ it "should replace incidences of %H in the path with the client's fully qualified name" do
+ @mount.path = "/dir/%H/yay"
+ @mount.path(@host).should == "/dir/host.domain.com/yay"
+ end
+
+ it "should replace incidences of %d in the path with the client's domain name" do
+ @mount.path = "/dir/%d/yay"
+ @mount.path(@host).should == "/dir/domain.com/yay"
+ end
+
+ it "should perform all necessary replacements" do
+ @mount.path = "/%h/%d/%H"
+ @mount.path(@host).should == "/host/domain.com/host.domain.com"
+ end
+
+ it "should use local host information if no client data is provided" do
+ stub_facter("myhost.mydomain.com")
+ @mount.path = "/%h/%d/%H"
+ @mount.path.should == "/myhost/mydomain.com/myhost.mydomain.com"
+ end
+
+ after do
+ Puppet::Util::Cacher.expire
+ end
end
describe Puppet::FileServing::Mount::File, "when determining the complete file path" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:exist?).returns(true)
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @mount.path = "/mount"
- stub_facter("myhost.mydomain.com")
- @host = "host.domain.com"
- end
-
- it "should return nil if the file is absent" do
- FileTest.stubs(:exist?).returns(false)
- @mount.complete_path("/my/path", nil).should be_nil
- end
-
- it "should write a log message if the file is absent" do
- FileTest.stubs(:exist?).returns(false)
-
- Puppet.expects(:info).with("File does not exist or is not accessible: /mount/my/path")
-
- @mount.complete_path("/my/path", nil)
- end
-
- it "should return the file path if the file is present" do
- FileTest.stubs(:exist?).with("/my/path").returns(true)
- @mount.complete_path("/my/path", nil).should == "/mount/my/path"
- end
-
- it "should treat a nil file name as the path to the mount itself" do
- FileTest.stubs(:exist?).returns(true)
- @mount.complete_path(nil, nil).should == "/mount"
- end
-
- it "should use the client host name if provided in the options" do
- @mount.path = "/mount/%h"
- @mount.complete_path("/my/path", @host).should == "/mount/host/my/path"
- end
-
- it "should perform replacements on the base path" do
- @mount.path = "/blah/%h"
- @mount.complete_path("/my/stuff", @host).should == "/blah/host/my/stuff"
- end
-
- it "should not perform replacements on the per-file path" do
- @mount.path = "/blah"
- @mount.complete_path("/%h/stuff", @host).should == "/blah/%h/stuff"
- end
-
- it "should look for files relative to its base directory" do
- @mount.complete_path("/my/stuff", @host).should == "/mount/my/stuff"
- end
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:exist?).returns(true)
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @mount.path = "/mount"
+ stub_facter("myhost.mydomain.com")
+ @host = "host.domain.com"
+ end
+
+ it "should return nil if the file is absent" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.complete_path("/my/path", nil).should be_nil
+ end
+
+ it "should write a log message if the file is absent" do
+ FileTest.stubs(:exist?).returns(false)
+
+ Puppet.expects(:info).with("File does not exist or is not accessible: /mount/my/path")
+
+ @mount.complete_path("/my/path", nil)
+ end
+
+ it "should return the file path if the file is present" do
+ FileTest.stubs(:exist?).with("/my/path").returns(true)
+ @mount.complete_path("/my/path", nil).should == "/mount/my/path"
+ end
+
+ it "should treat a nil file name as the path to the mount itself" do
+ FileTest.stubs(:exist?).returns(true)
+ @mount.complete_path(nil, nil).should == "/mount"
+ end
+
+ it "should use the client host name if provided in the options" do
+ @mount.path = "/mount/%h"
+ @mount.complete_path("/my/path", @host).should == "/mount/host/my/path"
+ end
+
+ it "should perform replacements on the base path" do
+ @mount.path = "/blah/%h"
+ @mount.complete_path("/my/stuff", @host).should == "/blah/host/my/stuff"
+ end
+
+ it "should not perform replacements on the per-file path" do
+ @mount.path = "/blah"
+ @mount.complete_path("/%h/stuff", @host).should == "/blah/%h/stuff"
+ end
+
+ it "should look for files relative to its base directory" do
+ @mount.complete_path("/my/stuff", @host).should == "/mount/my/stuff"
+ end
end
describe Puppet::FileServing::Mount::File, "when finding files" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:exist?).returns(true)
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @mount.path = "/mount"
- stub_facter("myhost.mydomain.com")
- @host = "host.domain.com"
-
- @request = stub 'request', :node => "foo"
- end
-
- it "should return the results of the complete file path" do
- FileTest.stubs(:exist?).returns(false)
- @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
- @mount.find("/my/path", @request).should == "eh"
- end
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:exist?).returns(true)
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @mount.path = "/mount"
+ stub_facter("myhost.mydomain.com")
+ @host = "host.domain.com"
+
+ @request = stub 'request', :node => "foo"
+ end
+
+ it "should return the results of the complete file path" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
+ @mount.find("/my/path", @request).should == "eh"
+ end
end
describe Puppet::FileServing::Mount::File, "when searching for files" do
- include FileServingMountTesting
-
- before do
- FileTest.stubs(:exist?).returns(true)
- FileTest.stubs(:directory?).returns(true)
- FileTest.stubs(:readable?).returns(true)
- @mount = Puppet::FileServing::Mount::File.new("test")
- @mount.path = "/mount"
- stub_facter("myhost.mydomain.com")
- @host = "host.domain.com"
-
- @request = stub 'request', :node => "foo"
- end
-
- it "should return the results of the complete file path as an array" do
- FileTest.stubs(:exist?).returns(false)
- @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
- @mount.search("/my/path", @request).should == ["eh"]
- end
-
- it "should return nil if the complete path is nil" do
- FileTest.stubs(:exist?).returns(false)
- @mount.expects(:complete_path).with("/my/path", "foo").returns nil
- @mount.search("/my/path", @request).should be_nil
- end
+ include FileServingMountTesting
+
+ before do
+ FileTest.stubs(:exist?).returns(true)
+ FileTest.stubs(:directory?).returns(true)
+ FileTest.stubs(:readable?).returns(true)
+ @mount = Puppet::FileServing::Mount::File.new("test")
+ @mount.path = "/mount"
+ stub_facter("myhost.mydomain.com")
+ @host = "host.domain.com"
+
+ @request = stub 'request', :node => "foo"
+ end
+
+ it "should return the results of the complete file path as an array" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.expects(:complete_path).with("/my/path", "foo").returns "eh"
+ @mount.search("/my/path", @request).should == ["eh"]
+ end
+
+ it "should return nil if the complete path is nil" do
+ FileTest.stubs(:exist?).returns(false)
+ @mount.expects(:complete_path).with("/my/path", "foo").returns nil
+ @mount.search("/my/path", @request).should be_nil
+ end
end
diff --git a/spec/unit/file_serving/mount/modules_spec.rb b/spec/unit/file_serving/mount/modules_spec.rb
index eeecc9aae..5450b85ad 100755
--- a/spec/unit/file_serving/mount/modules_spec.rb
+++ b/spec/unit/file_serving/mount/modules_spec.rb
@@ -4,60 +4,60 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/file_serving/mount/modules'
describe Puppet::FileServing::Mount::Modules do
- before do
- @mount = Puppet::FileServing::Mount::Modules.new("modules")
+ before do
+ @mount = Puppet::FileServing::Mount::Modules.new("modules")
- @environment = stub 'environment', :module => nil
- @request = stub 'request', :environment => @environment
- end
+ @environment = stub 'environment', :module => nil
+ @request = stub 'request', :environment => @environment
+ end
- describe "when finding files" do
- it "should use the provided environment to find the module" do
- @environment.expects(:module)
+ describe "when finding files" do
+ it "should use the provided environment to find the module" do
+ @environment.expects(:module)
- @mount.find("foo", @request)
- end
+ @mount.find("foo", @request)
+ end
- it "should treat the first field of the relative path as the module name" do
- @environment.expects(:module).with("foo")
- @mount.find("foo/bar/baz", @request)
- end
+ it "should treat the first field of the relative path as the module name" do
+ @environment.expects(:module).with("foo")
+ @mount.find("foo/bar/baz", @request)
+ end
- it "should return nil if the specified module does not exist" do
- @environment.expects(:module).with("foo").returns nil
- @mount.find("foo/bar/baz", @request)
- end
+ it "should return nil if the specified module does not exist" do
+ @environment.expects(:module).with("foo").returns nil
+ @mount.find("foo/bar/baz", @request)
+ end
- it "should return the file path from the module" do
- mod = mock 'module'
- mod.expects(:file).with("bar/baz").returns "eh"
- @environment.expects(:module).with("foo").returns mod
- @mount.find("foo/bar/baz", @request).should == "eh"
- end
+ it "should return the file path from the module" do
+ mod = mock 'module'
+ mod.expects(:file).with("bar/baz").returns "eh"
+ @environment.expects(:module).with("foo").returns mod
+ @mount.find("foo/bar/baz", @request).should == "eh"
end
+ end
- describe "when searching for files" do
- it "should use the node's environment to search the module" do
- @environment.expects(:module)
+ describe "when searching for files" do
+ it "should use the node's environment to search the module" do
+ @environment.expects(:module)
- @mount.search("foo", @request)
- end
+ @mount.search("foo", @request)
+ end
- it "should treat the first field of the relative path as the module name" do
- @environment.expects(:module).with("foo")
- @mount.search("foo/bar/baz", @request)
- end
+ it "should treat the first field of the relative path as the module name" do
+ @environment.expects(:module).with("foo")
+ @mount.search("foo/bar/baz", @request)
+ end
- it "should return nil if the specified module does not exist" do
- @environment.expects(:module).with("foo").returns nil
- @mount.search("foo/bar/baz", @request)
- end
+ it "should return nil if the specified module does not exist" do
+ @environment.expects(:module).with("foo").returns nil
+ @mount.search("foo/bar/baz", @request)
+ end
- it "should return the file path as an array from the module" do
- mod = mock 'module'
- mod.expects(:file).with("bar/baz").returns "eh"
- @environment.expects(:module).with("foo").returns mod
- @mount.search("foo/bar/baz", @request).should == ["eh"]
- end
+ it "should return the file path as an array from the module" do
+ mod = mock 'module'
+ mod.expects(:file).with("bar/baz").returns "eh"
+ @environment.expects(:module).with("foo").returns mod
+ @mount.search("foo/bar/baz", @request).should == ["eh"]
end
+ end
end
diff --git a/spec/unit/file_serving/mount/plugins_spec.rb b/spec/unit/file_serving/mount/plugins_spec.rb
index d8c05a2bd..b48b52509 100755
--- a/spec/unit/file_serving/mount/plugins_spec.rb
+++ b/spec/unit/file_serving/mount/plugins_spec.rb
@@ -4,58 +4,58 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/file_serving/mount/plugins'
describe Puppet::FileServing::Mount::Plugins do
- before do
- @mount = Puppet::FileServing::Mount::Plugins.new("plugins")
+ before do
+ @mount = Puppet::FileServing::Mount::Plugins.new("plugins")
- @environment = stub 'environment', :module => nil
- @request = stub 'request', :environment => @environment
- end
+ @environment = stub 'environment', :module => nil
+ @request = stub 'request', :environment => @environment
+ end
- describe "when finding files" do
- it "should use the provided environment to find the modules" do
- @environment.expects(:modules).returns []
+ describe "when finding files" do
+ it "should use the provided environment to find the modules" do
+ @environment.expects(:modules).returns []
- @mount.find("foo", @request)
- end
+ @mount.find("foo", @request)
+ end
- it "should return nil if no module can be found with a matching plugin" do
- mod = mock 'module'
- mod.stubs(:plugin).with("foo/bar").returns nil
+ it "should return nil if no module can be found with a matching plugin" do
+ mod = mock 'module'
+ mod.stubs(:plugin).with("foo/bar").returns nil
- @environment.stubs(:modules).returns [mod]
- @mount.find("foo/bar", @request).should be_nil
- end
+ @environment.stubs(:modules).returns [mod]
+ @mount.find("foo/bar", @request).should be_nil
+ end
- it "should return the file path from the module" do
- mod = mock 'module'
- mod.stubs(:plugin).with("foo/bar").returns "eh"
+ it "should return the file path from the module" do
+ mod = mock 'module'
+ mod.stubs(:plugin).with("foo/bar").returns "eh"
- @environment.stubs(:modules).returns [mod]
- @mount.find("foo/bar", @request).should == "eh"
- end
+ @environment.stubs(:modules).returns [mod]
+ @mount.find("foo/bar", @request).should == "eh"
end
+ end
- describe "when searching for files" do
- it "should use the node's environment to find the modules" do
- @environment.expects(:modules).returns []
+ describe "when searching for files" do
+ it "should use the node's environment to find the modules" do
+ @environment.expects(:modules).returns []
- @mount.search("foo", @request)
- end
+ @mount.search("foo", @request)
+ end
- it "should return nil if no modules can be found that have plugins" do
- mod = mock 'module'
- mod.stubs(:plugins?).returns false
+ it "should return nil if no modules can be found that have plugins" do
+ mod = mock 'module'
+ mod.stubs(:plugins?).returns false
- @environment.stubs(:modules).returns []
- @mount.search("foo/bar", @request).should be_nil
- end
+ @environment.stubs(:modules).returns []
+ @mount.search("foo/bar", @request).should be_nil
+ end
- it "should return the plugin paths for each module that has plugins" do
- one = stub 'module', :plugins? => true, :plugin_directory => "/one"
- two = stub 'module', :plugins? => true, :plugin_directory => "/two"
+ it "should return the plugin paths for each module that has plugins" do
+ one = stub 'module', :plugins? => true, :plugin_directory => "/one"
+ two = stub 'module', :plugins? => true, :plugin_directory => "/two"
- @environment.stubs(:modules).returns [one, two]
- @mount.search("foo/bar", @request).should == %w{/one /two}
- end
+ @environment.stubs(:modules).returns [one, two]
+ @mount.search("foo/bar", @request).should == %w{/one /two}
end
+ end
end