summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:04 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:04 -0700
commit9ee56f2e67be973da49b1d3f21de1bf87de35e6f (patch)
treeddab8c01509f47664c52c8a6b165bb5a974f138f /spec/unit/provider
parent051bd98751d9d4bc97f93f66723d9b7a00c0cfb4 (diff)
downloadpuppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.tar.gz
puppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.tar.xz
puppet-9ee56f2e67be973da49b1d3f21de1bf87de35e6f.zip
Code smell: Inconsistent indentation and related formatting issues
* Replaced 163 occurances of defined\? +([@a-zA-Z_.0-9?=]+) with defined?(\1) This makes detecting subsequent patterns easier. 3 Examples: The code: if ! defined? @parse_config becomes: if ! defined?(@parse_config) The code: return @option_parser if defined? @option_parser becomes: return @option_parser if defined?(@option_parser) The code: if defined? @local and @local becomes: if defined?(@local) and @local * Eliminate trailing spaces. Replaced 428 occurances of ^(.*?) +$ with \1 1 file was skipped. test/ral/providers/host/parsed.rb because 0 * Replace leading tabs with an appropriate number of spaces. Replaced 306 occurances of ^(\t+)(.*) with Tabs are not consistently expanded in all environments. * Don't arbitrarily wrap on sprintf (%) operator. Replaced 143 occurances of (.*['"] *%) +(.*) with Splitting the line does nothing to aid clarity and hinders further refactorings. 3 Examples: The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] The code: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] becomes: $stderr.puts "Could not find host for PID %s with status %s" % [pid, $?.exitstatus] * Don't break short arrays/parameter list in two. Replaced 228 occurances of (.*) +(.*) with 3 Examples: The code: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) becomes: puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) The code: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) becomes: assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) The code: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") becomes: assert(prov.target_object(:first).read !~ /^notdisk/, "Did not remove thing from disk") * If arguments must wrap, treat them all equally Replaced 510 occurances of lines ending in things like ...(foo, or ...(bar(1,3), with \1 \2 3 Examples: The code: midscope.to_hash(false), becomes: assert_equal( The code: botscope.to_hash(true), becomes: # bottomscope, then checking that we see the right stuff. The code: :path => link, becomes: * Replaced 4516 occurances of ^( *)(.*) with The present code base is supposed to use four-space indentation. In some places we failed to maintain that standard. These should be fixed regardless of the 2 vs. 4 space question. 15 Examples: The code: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc becomes: def run_comp(cmd) puts cmd results = [] old_sync = $stdout.sync $stdout.sync = true line = [] begin open("| #{cmd}", "r") do |f| until f.eof? do c = f.getc The code: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( becomes: s.gsub!(/.{4}/n, '\\\\u\&') } string.force_encoding(Encoding::UTF_8) string rescue Iconv::Failure => e raise GeneratorError, "Caught #{e.class}: #{e}" end else def utf8_to_pson(string) # :nodoc: string = string.gsub(/["\\\x0-\x1f]/) { MAP[$&] } string.gsub!(/( The code: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } becomes: end } rvalues: rvalue | rvalues comma rvalue { if val[0].instance_of?(AST::ASTArray) result = val[0].push(val[2]) else result = ast AST::ASTArray, :children => [val[0],val[2]] end } The code: #passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } becomes: # passwdproc = proc { @password } keytext = @key.export( OpenSSL::Cipher::DES.new(:EDE3, :CBC), @password ) File.open(@keyfile, "w", 0400) { |f| f << keytext } The code: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") becomes: end def to_manifest "%s { '%s':\n%s\n}" % [self.type.to_s, self.name, @params.collect { |p, v| if v.is_a? Array " #{p} => [\'#{v.join("','")}\']" else " #{p} => \'#{v}\'" end }.join(",\n") The code: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", becomes: via the augeas tool. Requires: - augeas to be installed (http://www.augeas.net) - ruby-augeas bindings Sample usage with a string:: augeas{\"test1\" : context => \"/files/etc/sysconfig/firstboot\", changes => \"set RUN_FIRSTBOOT YES\", The code: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do becomes: names.should_not be_include("root") end describe "when generating a purgeable resource" do it "should be included in the generated resources" do Puppet::Type.type(:host).stubs(:instances).returns [@purgeable_resource] @resources.generate.collect { |r| r.ref }.should include(@purgeable_resource.ref) end end describe "when the instance's do not have an ensure property" do The code: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') becomes: describe "when the instance's do not have an ensure property" do it "should not be included in the generated resources" do @no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo') Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource] @resources.generate.collect { |r| r.ref }.should_not include(@no_ensure_resource.ref) end end describe "when the instance's ensure property does not accept absent" do it "should not be included in the generated resources" do @no_absent_resource = Puppet::Type.type(:service).new(:name => 'foobar') The code: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) becomes: func = nil assert_nothing_raised do func = Puppet::Parser::AST::Function.new( :name => "template", :ftype => :rvalue, :arguments => AST::ASTArray.new( :children => [stringobj(template)] ) The code: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") becomes: assert( @store.allowed?("hostname.madstop.com", "192.168.1.50"), "hostname not allowed") assert( ! @store.allowed?("name.sub.madstop.com", "192.168.0.50"), "subname name allowed") The code: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } becomes: assert_nothing_raised { server = Puppet::Network::Handler.fileserver.new( :Local => true, :Config => false ) } The code: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid becomes: 'yay', { :failonfail => false, :uid => @user.uid, :gid => @user.gid } ).returns('output') output = Puppet::Util::SUIDManager.run_and_capture 'yay', @user.uid, @user.gid The code: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' becomes: ).times(1) pkg.provider.expects( :aptget ).with( '-y', '-q', 'remove', 'faff' The code: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs becomes: johnny one two billy three four\n" # Just parse and generate, to make sure it's isomorphic. assert_nothing_raised do assert_equal(text, @parser.to_file(@parser.parse(text)), "parsing was not isomorphic") end end def test_valid_attrs The code: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element| becomes: "testing", :onboolean => [true, "An on bool"], :string => ["a string", "A string arg"] ) result = [] should = [] assert_nothing_raised("Add args failed") do @config.addargs(result) end @config.each do |name, element|
Diffstat (limited to 'spec/unit/provider')
-rwxr-xr-xspec/unit/provider/mount/parsed_spec.rb4
-rwxr-xr-xspec/unit/provider/package/apt_spec.rb2
-rwxr-xr-xspec/unit/provider/package/dpkg_spec.rb6
-rw-r--r--spec/unit/provider/package/hpux_spec.rb2
-rwxr-xr-xspec/unit/provider/package/nim_spec.rb2
-rw-r--r--spec/unit/provider/package/pkg_spec.rb26
-rwxr-xr-xspec/unit/provider/package/pkgdmg_spec.rb10
-rw-r--r--spec/unit/provider/package/zypper_spec.rb8
-rwxr-xr-xspec/unit/provider/selmodule_spec.rb2
-rwxr-xr-xspec/unit/provider/service/daemontools_spec.rb2
-rwxr-xr-xspec/unit/provider/service/debian_spec.rb10
-rwxr-xr-xspec/unit/provider/service/init_spec.rb16
-rwxr-xr-xspec/unit/provider/service/launchd_spec.rb14
-rwxr-xr-xspec/unit/provider/service/redhat_spec.rb12
-rwxr-xr-xspec/unit/provider/service/runit_spec.rb2
-rwxr-xr-xspec/unit/provider/service/src_spec.rb6
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed_spec.rb34
-rwxr-xr-xspec/unit/provider/sshkey/parsed_spec.rb12
-rw-r--r--spec/unit/provider/user/user_role_add_spec.rb24
19 files changed, 100 insertions, 94 deletions
diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb
index 0cf206d4b..4dc33708e 100755
--- a/spec/unit/provider/mount/parsed_spec.rb
+++ b/spec/unit/provider/mount/parsed_spec.rb
@@ -29,7 +29,7 @@ module ParsedMountTesting
def mkmountargs
mount = nil
- if defined? @pcount
+ if defined?(@pcount)
@pcount += 1
else
@pcount = 1
@@ -151,7 +151,7 @@ describe provider_class do
it "should write the mount to disk when :flush is called" do
old_text = @provider_class.target_object(@provider_class.default_target).read
-
+
@mount.flush
text = @provider_class.target_object(@provider_class.default_target).read
diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb
index 861029838..54f2c0771 100755
--- a/spec/unit/provider/package/apt_spec.rb
+++ b/spec/unit/provider/package/apt_spec.rb
@@ -39,7 +39,7 @@ describe provider do
Installed: 1:1.0
Candidate: 1:1.1
Version table:
- 1:1.0
+1:1.0
650 http://ftp.osuosl.org testing/main Packages
*** 1:1.1
100 /var/lib/dpkg/status"
diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb
index d0c1d2622..68ffb19a4 100755
--- a/spec/unit/provider/package/dpkg_spec.rb
+++ b/spec/unit/provider/package/dpkg_spec.rb
@@ -163,9 +163,9 @@ describe provider do
describe "when holding or unholding" do
before do
- @tempfile = stub 'tempfile', :print => nil, :close => nil, :flush => nil, :path => "/other/file"
- @tempfile.stubs(:write)
- Tempfile.stubs(:new).returns @tempfile
+ @tempfile = stub 'tempfile', :print => nil, :close => nil, :flush => nil, :path => "/other/file"
+ @tempfile.stubs(:write)
+ Tempfile.stubs(:new).returns @tempfile
end
it "should install first if holding" do
diff --git a/spec/unit/provider/package/hpux_spec.rb b/spec/unit/provider/package/hpux_spec.rb
index 32eae5189..8343c6052 100644
--- a/spec/unit/provider/package/hpux_spec.rb
+++ b/spec/unit/provider/package/hpux_spec.rb
@@ -49,4 +49,4 @@ describe provider_class do
@provider.uninstall
end
end
- end
+end
diff --git a/spec/unit/provider/package/nim_spec.rb b/spec/unit/provider/package/nim_spec.rb
index 2018f6506..5d9083b70 100755
--- a/spec/unit/provider/package/nim_spec.rb
+++ b/spec/unit/provider/package/nim_spec.rb
@@ -39,4 +39,4 @@ describe provider_class do
@provider.install
end
end
- end
+end
diff --git a/spec/unit/provider/package/pkg_spec.rb b/spec/unit/provider/package/pkg_spec.rb
index d0d933d5e..b29405e26 100644
--- a/spec/unit/provider/package/pkg_spec.rb
+++ b/spec/unit/provider/package/pkg_spec.rb
@@ -19,36 +19,36 @@ describe provider do
end
end
end
-
+
it_should_respond_to :install, :uninstall, :update, :query, :latest
-
+
it "should be versionable" do
provider.should_not be_versionable
end
-
+
it "should use :install to update" do
@provider.expects(:install)
@provider.update
end
-
+
it "should parse a line correctly" do
result = provider.parse_line("dummy 1.0@1.0-1.0 installed ----")
result.should == {:name => "dummy", :version => "1.0@1.0-1.0",
- :ensure => :present, :status => "installed",
- :provider => :pkg, :error => "ok"}
+ :ensure => :present, :status => "installed",
+ :provider => :pkg, :error => "ok"}
end
-
+
it "should fail to parse an incorrect line" do
- result = provider.parse_line("foo")
- result.should be_nil
+ result = provider.parse_line("foo")
+ result.should be_nil
end
it "should fail to list a missing package" do
@provider.expects(:pkg).with(:list, "-H", "dummy").returns "1"
@provider.query.should == {:status=>"missing", :ensure=>:absent,
- :name=>"dummy", :error=>"ok"}
+ :name=>"dummy", :error=>"ok"}
end
-
+
it "should fail to list a package when it can't parse the output line" do
@provider.expects(:pkg).with(:list, "-H", "dummy").returns "failed"
@provider.query.should == {:status=>"missing", :ensure=>:absent, :name=>"dummy", :error=>"ok"}
@@ -57,7 +57,7 @@ describe provider do
it "should list package correctly" do
@provider.expects(:pkg).with(:list, "-H", "dummy").returns "dummy 1.0@1.0-1.0 installed ----"
@provider.query.should == {:name => "dummy", :version => "1.0@1.0-1.0",
- :ensure => :present, :status => "installed",
- :provider => :pkg, :error => "ok"}
+ :ensure => :present, :status => "installed",
+ :provider => :pkg, :error => "ok"}
end
end
diff --git a/spec/unit/provider/package/pkgdmg_spec.rb b/spec/unit/provider/package/pkgdmg_spec.rb
index 3f007e01b..d4c5a9287 100755
--- a/spec/unit/provider/package/pkgdmg_spec.rb
+++ b/spec/unit/provider/package/pkgdmg_spec.rb
@@ -15,7 +15,7 @@ describe provider do
@fakehdiutilplist = Plist::Emit.dump(@fakehdiutilinfo)
@hdiutilmountargs = ["mount", "-plist", "-nobrowse", "-readonly",
- "-noidme", "-mountrandom", "/tmp"]
+ "-noidme", "-mountrandom", "/tmp"]
end
it "should not be versionable" do
@@ -76,9 +76,9 @@ describe provider do
it "should call installpkg if a flat pkg file is found instead of a .dmg image" do
@resource.stubs(:[]).with(:source).returns "/tmp/test.pkg"
@resource.stubs(:[]).with(:name).returns "testpkg"
- @provider.class.expects(:installpkgdmg).with("#{@fakepkgfile}", "testpkg").returns ""
- @provider.install
- end
+ @provider.class.expects(:installpkgdmg).with("#{@fakepkgfile}", "testpkg").returns ""
+ @provider.install
+ end
end
-
+
end
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index be45a4cc7..b7f3687c6 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -68,14 +68,14 @@ describe provider_class do
fake_data = "Loading repository data...
Reading installed packages...
-S | Repository | Name | Version | Arch
+S | Repository | Name | Version | Arch
--+----------------+-----------------------+-----------------+-------
v | SLES11-Updates | cups | 1.1.1 | x86_64
v | SLES11-Updates | mypackage | 1.3.9h-8.20.1 | x86_64"
- @provider.expects(:zypper).with("list-updates").returns fake_data
- @provider.latest.should == "1.3.9h-8.20.1"
+ @provider.expects(:zypper).with("list-updates").returns fake_data
+ @provider.latest.should == "1.3.9h-8.20.1"
end
end
- end
+end
diff --git a/spec/unit/provider/selmodule_spec.rb b/spec/unit/provider/selmodule_spec.rb
index 5f60322d8..ed20ea97f 100755
--- a/spec/unit/provider/selmodule_spec.rb
+++ b/spec/unit/provider/selmodule_spec.rb
@@ -61,6 +61,6 @@ describe provider_class do
@provider.syncversion.should == :false
end
- end
+ end
end
diff --git a/spec/unit/provider/service/daemontools_spec.rb b/spec/unit/provider/service/daemontools_spec.rb
index a2198bb9d..2d61d2322 100755
--- a/spec/unit/provider/service/daemontools_spec.rb
+++ b/spec/unit/provider/service/daemontools_spec.rb
@@ -163,4 +163,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/debian_spec.rb b/spec/unit/provider/service/debian_spec.rb
index ea87c375d..08cf50c27 100755
--- a/spec/unit/provider/service/debian_spec.rb
+++ b/spec/unit/provider/service/debian_spec.rb
@@ -57,25 +57,25 @@ describe provider_class do
@provider.disable
end
end
-
+
describe "when checking whether it is enabled" do
it "should call Kernel.system() with the appropriate parameters" do
@provider.expects(:system).with("/usr/sbin/invoke-rc.d", "--quiet", "--query", @resource[:name], "start").once
@provider.enabled?
end
-
+
it "should return true when invoke-rc.d exits with 104 status" do
@provider.stubs(:system)
$?.stubs(:exitstatus).returns(104)
@provider.enabled?.should == :true
end
-
+
it "should return true when invoke-rc.d exits with 106 status" do
@provider.stubs(:system)
$?.stubs(:exitstatus).returns(106)
@provider.enabled?.should == :true
end
-
+
# pick a range of non-[104.106] numbers, strings and booleans to test with.
[-100, -1, 0, 1, 100, "foo", "", :true, :false].each do |exitstatus|
it "should return false when invoke-rc.d exits with #{exitstatus} status" do
@@ -86,4 +86,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/init_spec.rb b/spec/unit/provider/service/init_spec.rb
index 6dd42f54c..a685cc0d0 100755
--- a/spec/unit/provider/service/init_spec.rb
+++ b/spec/unit/provider/service/init_spec.rb
@@ -18,13 +18,13 @@ describe provider_class do
@resource.stubs(:[]).with(:path).returns ["/service/path","/alt/service/path"]
# @resource.stubs(:ref).returns "Service[myservice]"
File.stubs(:directory?).returns(true)
-
+
@provider = provider_class.new
@provider.resource = @resource
end
describe "when getting all service instances" do
- before :each do
+ before :each do
@services = ['one', 'two', 'three', 'four']
Dir.stubs(:entries).returns @services
FileTest.stubs(:directory?).returns(true)
@@ -59,14 +59,14 @@ describe provider_class do
@class.expects(:new).with{|hash| hash[:path] == @class.defpath}.returns("#{inst}_instance")
end
results = @services.sort.collect {|x| "#{x}_instance"}
- @class.instances.sort.should == results
+ @class.instances.sort.should == results
end
it "should set hasstatus to true for providers" do
@services.each do |inst|
@class.expects(:new).with{|hash| hash[:name] == inst && hash[:hasstatus] == true}.returns("#{inst}_instance")
end
results = @services.collect {|x| "#{x}_instance"}
- @class.instances.should == results
+ @class.instances.should == results
end
end
@@ -95,18 +95,18 @@ describe provider_class do
lambda { @provider.initscript }.should raise_error(Puppet::Error, "Could not find init script for 'myservice'")
end
end
-
+
describe "if the init script is present" do
before :each do
File.stubs(:stat).with("/service/path/myservice").returns true
end
-
+
[:start, :stop, :status, :restart].each do |method|
it "should have a #{method} method" do
@provider.should respond_to(method)
end
describe "when running #{method}" do
-
+
it "should use any provided explicit command" do
@resource.stubs(:[]).with(method).returns "/user/specified/command"
@provider.expects(:execute).with { |command, *args| command == ["/user/specified/command"] }
@@ -117,7 +117,7 @@ describe provider_class do
@resource.stubs(:[]).with("has#{method}".intern).returns :true
@provider.expects(:execute).with { |command, *args| command == ["/service/path/myservice",method]}
@provider.send(method)
- end
+ end
end
end
diff --git a/spec/unit/provider/service/launchd_spec.rb b/spec/unit/provider/service/launchd_spec.rb
index fa86a21a5..62570e2a8 100755
--- a/spec/unit/provider/service/launchd_spec.rb
+++ b/spec/unit/provider/service/launchd_spec.rb
@@ -33,10 +33,10 @@ describe provider_class do
@provider.stubs(:plist_from_label).returns([@joblabel, @jobplist])
@provider.stubs(:execute).returns("")
@provider.stubs(:resource).returns @resource
-
+
# We stub this out for the normal case as 10.6 is "special".
provider_class.stubs(:get_macosx_version_major).returns("10.5")
-
+
end
it "should have a start method for #{@provider.object_id}" do
@@ -78,7 +78,7 @@ describe provider_class do
@provider.status.should == :running
end
end
-
+
describe "when checking whether the service is enabled" do
it "should return true if the job plist says disabled is false" do
@provider.stubs(:plist_from_label).returns(["foo", {"Disabled" => false}])
@@ -93,7 +93,7 @@ describe provider_class do
@provider.enabled?.should == :false
end
end
-
+
describe "when checking whether the service is enabled on OS X 10.6" do
it "should return true if the job plist says disabled is true and the global overrides says disabled is false" do
provider_class.stubs(:get_macosx_version_major).returns("10.6")
@@ -178,7 +178,7 @@ describe provider_class do
@provider.stop
end
end
-
+
describe "when enabling the service on OS X 10.6" do
it "should write to the global launchd overrides file once" do
provider_class.stubs(:get_macosx_version_major).returns("10.6")
@@ -187,7 +187,7 @@ describe provider_class do
@provider.enable
end
end
-
+
describe "when disabling the service on OS X 10.6" do
it "should write to the global launchd overrides file once" do
provider_class.stubs(:get_macosx_version_major).returns("10.6")
@@ -197,4 +197,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb
index 591ef2d96..0f919ac84 100755
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -20,10 +20,10 @@ describe provider_class do
FileTest.stubs(:file?).with('/sbin/service').returns true
FileTest.stubs(:executable?).with('/sbin/service').returns true
end
-
+
# test self.instances
describe "when getting all service instances" do
- before :each do
+ before :each do
@services = ['one', 'two', 'three', 'four', 'kudzu', 'functions', 'halt', 'killall', 'single', 'linuxconf']
@not_services = ['functions', 'halt', 'killall', 'single', 'linuxconf']
Dir.stubs(:entries).returns @services
@@ -62,7 +62,7 @@ describe provider_class do
@provider.should respond_to(method)
end
describe "when running #{method}" do
-
+
it "should use any provided explicit command" do
@resource.stubs(:[]).with(method).returns "/user/specified/command"
@provider.expects(:execute).with { |command, *args| command == ["/user/specified/command"] }
@@ -73,7 +73,7 @@ describe provider_class do
@resource.stubs(:[]).with("has#{method}".intern).returns :true
@provider.expects(:execute).with { |command, *args| command == ['/sbin/service', 'myservice', method.to_s]}
@provider.send(method)
- end
+ end
end
end
@@ -105,8 +105,8 @@ describe provider_class do
@provider.status.should == :running
end
it "should consider the service :stopped if it doesn't have a pid" do
- @provider.expects(:getpid).returns nil
- @provider.status.should == :stopped
+ @provider.expects(:getpid).returns nil
+ @provider.status.should == :stopped
end
end
end
diff --git a/spec/unit/provider/service/runit_spec.rb b/spec/unit/provider/service/runit_spec.rb
index dd8d0dac1..42309ee5f 100755
--- a/spec/unit/provider/service/runit_spec.rb
+++ b/spec/unit/provider/service/runit_spec.rb
@@ -137,4 +137,4 @@ describe provider_class do
end
end
- end
+end
diff --git a/spec/unit/provider/service/src_spec.rb b/spec/unit/provider/service/src_spec.rb
index 76a6cf850..eaa968f6e 100755
--- a/spec/unit/provider/service/src_spec.rb
+++ b/spec/unit/provider/service/src_spec.rb
@@ -34,12 +34,12 @@ describe provider_class do
end
end
- it "should execute the startsrc command" do
+ it "should execute the startsrc command" do
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:squelch => true, :failonfail => true})
@provider.start
- end
+ end
- it "should execute the stopsrc command" do
+ it "should execute the stopsrc command" do
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:squelch => true, :failonfail => true})
@provider.stop
end
diff --git a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
index 9fdd7f499..3b14ad3d7 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed_spec.rb
@@ -56,24 +56,30 @@ describe provider_class do
}
it "should be able to generate a basic authorized_keys file" do
- key = mkkey({
- :name => "Just Testing",
- :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
- :type => "ssh-dss",
- :ensure => :present,
- :options => [:absent]
+
+ key = mkkey(
+ {
+ :name => "Just Testing",
+ :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
+ :type => "ssh-dss",
+ :ensure => :present,
+
+ :options => [:absent]
})
genkey(key).should == "ssh-dss AAAAfsfddsjldjgksdflgkjsfdlgkj Just Testing\n"
end
it "should be able to generate a authorized_keys file with options" do
- key = mkkey({
- :name => "root@localhost",
- :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
- :type => "ssh-rsa",
- :ensure => :present,
- :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"]
+
+ key = mkkey(
+ {
+ :name => "root@localhost",
+ :key => "AAAAfsfddsjldjgksdflgkjsfdlgkj",
+ :type => "ssh-rsa",
+ :ensure => :present,
+
+ :options => ['from="192.168.1.1"', "no-pty", "no-X11-forwarding"]
})
genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n"
@@ -117,7 +123,7 @@ describe provider_class do
@resource.stubs(:should).with(:user).returns "random_bob"
target = "/tmp/.ssh_dir/place_to_put_authorized_keys"
@resource.stubs(:should).with(:target).returns target
- end
+ end
it "should create the directory" do
File.stubs(:exist?).with("/tmp/.ssh_dir").returns false
@@ -147,7 +153,7 @@ describe provider_class do
before :each do
@resource.stubs(:should).with(:user).returns "nobody"
@resource.stubs(:should).with(:target).returns nil
- #
+ #
# I'd like to use random_bob here and something like
#
# File.stubs(:expand_path).with("~random_bob/.ssh").returns "/users/r/random_bob/.ssh"
diff --git a/spec/unit/provider/sshkey/parsed_spec.rb b/spec/unit/provider/sshkey/parsed_spec.rb
index fc6c85dbd..4180ffbaf 100755
--- a/spec/unit/provider/sshkey/parsed_spec.rb
+++ b/spec/unit/provider/sshkey/parsed_spec.rb
@@ -11,27 +11,27 @@ describe provider_class do
@key = 'AAAAB3NzaC1yc2EAAAABIwAAAQEAzwHhxXvIrtfIwrudFqc8yQcIfMudrgpnuh1F3AV6d2BrLgu/yQE7W5UyJMUjfj427sQudRwKW45O0Jsnr33F4mUw+GIMlAAmp9g24/OcrTiB8ZUKIjoPy/cO4coxGi8/NECtRzpD/ZUPFh6OEpyOwJPMb7/EC2Az6Otw4StHdXUYw22zHazBcPFnv6zCgPx1hA7QlQDWTu4YcL0WmTYQCtMUb3FUqrcFtzGDD0ytosgwSd+JyN5vj5UwIABjnNOHPZ62EY1OFixnfqX/+dUwrFSs5tPgBF/KkC6R7tmbUfnBON6RrGEmu+ajOTOLy23qUZB4CQ53V7nyAWhzqSK+hw=='
end
- it "should parse the name from the first field" do
+ it "should parse the name from the first field" do
@provider_class.parse_line('test ssh-rsa '+@key)[:name].should == "test"
end
- it "should parse the first component of the first field as the name" do
+ it "should parse the first component of the first field as the name" do
@provider_class.parse_line('test,alias ssh-rsa '+@key)[:name].should == "test"
end
- it "should parse host_aliases from the remaining components of the first field" do
+ it "should parse host_aliases from the remaining components of the first field" do
@provider_class.parse_line('test,alias ssh-rsa '+@key)[:host_aliases].should == ["alias"]
end
- it "should parse multiple host_aliases" do
+ it "should parse multiple host_aliases" do
@provider_class.parse_line('test,alias1,alias2,alias3 ssh-rsa '+@key)[:host_aliases].should == ["alias1","alias2","alias3"]
end
- it "should not drop an empty host_alias" do
+ it "should not drop an empty host_alias" do
@provider_class.parse_line('test,alias, ssh-rsa '+@key)[:host_aliases].should == ["alias",""]
end
- it "should recognise when there are no host aliases" do
+ it "should recognise when there are no host aliases" do
@provider_class.parse_line('test ssh-rsa '+@key)[:host_aliases].should == []
end
diff --git a/spec/unit/provider/user/user_role_add_spec.rb b/spec/unit/provider/user/user_role_add_spec.rb
index 781eba428..4dbfb83be 100644
--- a/spec/unit/provider/user/user_role_add_spec.rb
+++ b/spec/unit/provider/user/user_role_add_spec.rb
@@ -68,40 +68,40 @@ describe provider_class do
end
end
- describe "when calling destroy" do
- it "should use the delete command if the user exists and is not a role" do
+ describe "when calling destroy" do
+ it "should use the delete command if the user exists and is not a role" do
@provider.stubs(:exists?).returns(true)
@provider.stubs(:is_role?).returns(false)
@provider.expects(:deletecmd)
@provider.expects(:run)
@provider.destroy
- end
+ end
- it "should use the delete command if the user is a role" do
+ it "should use the delete command if the user is a role" do
@provider.stubs(:exists?).returns(true)
@provider.stubs(:is_role?).returns(true)
@provider.expects(:deletecmd)
@provider.expects(:run)
@provider.destroy
- end
- end
+ end
+ end
- describe "when calling create_role" do
- it "should use the transition(role) if the user exists" do
+ describe "when calling create_role" do
+ it "should use the transition(role) if the user exists" do
@provider.stubs(:exists?).returns(true)
@provider.stubs(:is_role?).returns(false)
@provider.expects(:transition).with("role")
@provider.expects(:run)
@provider.create_role
- end
+ end
- it "should use the add command when role doesn't exists" do
+ it "should use the add command when role doesn't exists" do
@provider.stubs(:exists?).returns(false)
@provider.expects(:addcmd)
@provider.expects(:run)
@provider.create_role
- end
- end
+ end
+ end
describe "when allow duplicate is enabled" do
before do