diff options
| author | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
|---|---|---|
| committer | Markus Roberts <Markus@reality.com> | 2010-07-09 18:12:17 -0700 |
| commit | 3180b9d9b2c844dade1d361326600f7001ec66dd (patch) | |
| tree | 98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /spec/unit/indirector/key | |
| parent | 543225970225de5697734bfaf0a6eee996802c04 (diff) | |
| download | puppet-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/indirector/key')
| -rwxr-xr-x | spec/unit/indirector/key/ca_spec.rb | 30 | ||||
| -rwxr-xr-x | spec/unit/indirector/key/file_spec.rb | 142 |
2 files changed, 86 insertions, 86 deletions
diff --git a/spec/unit/indirector/key/ca_spec.rb b/spec/unit/indirector/key/ca_spec.rb index 964b0b0ed..9ed5df67b 100755 --- a/spec/unit/indirector/key/ca_spec.rb +++ b/spec/unit/indirector/key/ca_spec.rb @@ -8,21 +8,21 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/indirector/key/ca' describe Puppet::SSL::Key::Ca do - it "should have documentation" do - Puppet::SSL::Key::Ca.doc.should be_instance_of(String) - end + it "should have documentation" do + Puppet::SSL::Key::Ca.doc.should be_instance_of(String) + end - it "should use the :privatekeydir as the collection directory" do - Puppet.settings.expects(:value).with(:privatekeydir).returns "/key/dir" - Puppet::SSL::Key::Ca.collection_directory.should == "/key/dir" - end + it "should use the :privatekeydir as the collection directory" do + Puppet.settings.expects(:value).with(:privatekeydir).returns "/key/dir" + Puppet::SSL::Key::Ca.collection_directory.should == "/key/dir" + end - it "should store the ca key at the :cakey location" do - Puppet.settings.stubs(:use) - Puppet.settings.stubs(:value).returns "whatever" - Puppet.settings.stubs(:value).with(:cakey).returns "/ca/key" - file = Puppet::SSL::Key::Ca.new - file.stubs(:ca?).returns true - file.path("whatever").should == "/ca/key" - end + it "should store the ca key at the :cakey location" do + Puppet.settings.stubs(:use) + Puppet.settings.stubs(:value).returns "whatever" + Puppet.settings.stubs(:value).with(:cakey).returns "/ca/key" + file = Puppet::SSL::Key::Ca.new + file.stubs(:ca?).returns true + file.path("whatever").should == "/ca/key" + end end diff --git a/spec/unit/indirector/key/file_spec.rb b/spec/unit/indirector/key/file_spec.rb index f365bfd60..5037c7f0e 100755 --- a/spec/unit/indirector/key/file_spec.rb +++ b/spec/unit/indirector/key/file_spec.rb @@ -8,97 +8,97 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/indirector/key/file' describe Puppet::SSL::Key::File do - it "should have documentation" do - Puppet::SSL::Key::File.doc.should be_instance_of(String) + it "should have documentation" do + Puppet::SSL::Key::File.doc.should be_instance_of(String) + end + + it "should use the :privatekeydir as the collection directory" do + Puppet.settings.expects(:value).with(:privatekeydir).returns "/key/dir" + Puppet::SSL::Key::File.collection_directory.should == "/key/dir" + end + + it "should store the ca key at the :cakey location" do + Puppet.settings.stubs(:use) + Puppet.settings.stubs(:value).returns "whatever" + Puppet.settings.stubs(:value).with(:cakey).returns "/ca/key" + file = Puppet::SSL::Key::File.new + file.stubs(:ca?).returns true + file.path("whatever").should == "/ca/key" + end + + describe "when choosing the path for the public key" do + it "should use the :capub setting location if the key is for the certificate authority" do + Puppet.settings.stubs(:value).returns "/fake/dir" + Puppet.settings.stubs(:value).with(:capub).returns "/ca/pubkey" + Puppet.settings.stubs(:use) + + @searcher = Puppet::SSL::Key::File.new + @searcher.stubs(:ca?).returns true + @searcher.public_key_path("whatever").should == "/ca/pubkey" end - it "should use the :privatekeydir as the collection directory" do - Puppet.settings.expects(:value).with(:privatekeydir).returns "/key/dir" - Puppet::SSL::Key::File.collection_directory.should == "/key/dir" - end - - it "should store the ca key at the :cakey location" do - Puppet.settings.stubs(:use) - Puppet.settings.stubs(:value).returns "whatever" - Puppet.settings.stubs(:value).with(:cakey).returns "/ca/key" - file = Puppet::SSL::Key::File.new - file.stubs(:ca?).returns true - file.path("whatever").should == "/ca/key" - end + it "should use the host name plus '.pem' in :publickeydir for normal hosts" do + Puppet.settings.stubs(:value).with(:privatekeydir).returns "/private/key/dir" + Puppet.settings.stubs(:value).with(:publickeydir).returns "/public/key/dir" + Puppet.settings.stubs(:use) - describe "when choosing the path for the public key" do - it "should use the :capub setting location if the key is for the certificate authority" do - Puppet.settings.stubs(:value).returns "/fake/dir" - Puppet.settings.stubs(:value).with(:capub).returns "/ca/pubkey" - Puppet.settings.stubs(:use) - - @searcher = Puppet::SSL::Key::File.new - @searcher.stubs(:ca?).returns true - @searcher.public_key_path("whatever").should == "/ca/pubkey" - end - - it "should use the host name plus '.pem' in :publickeydir for normal hosts" do - Puppet.settings.stubs(:value).with(:privatekeydir).returns "/private/key/dir" - Puppet.settings.stubs(:value).with(:publickeydir).returns "/public/key/dir" - Puppet.settings.stubs(:use) - - @searcher = Puppet::SSL::Key::File.new - @searcher.stubs(:ca?).returns false - @searcher.public_key_path("whatever").should == "/public/key/dir/whatever.pem" - end + @searcher = Puppet::SSL::Key::File.new + @searcher.stubs(:ca?).returns false + @searcher.public_key_path("whatever").should == "/public/key/dir/whatever.pem" end + end - describe "when managing private keys" do - before do - @searcher = Puppet::SSL::Key::File.new + describe "when managing private keys" do + before do + @searcher = Puppet::SSL::Key::File.new - @private_key_path = File.join("/fake/key/path") - @public_key_path = File.join("/other/fake/key/path") + @private_key_path = File.join("/fake/key/path") + @public_key_path = File.join("/other/fake/key/path") - @searcher.stubs(:public_key_path).returns @public_key_path - @searcher.stubs(:path).returns @private_key_path + @searcher.stubs(:public_key_path).returns @public_key_path + @searcher.stubs(:path).returns @private_key_path - FileTest.stubs(:directory?).returns true - FileTest.stubs(:writable?).returns true + FileTest.stubs(:directory?).returns true + FileTest.stubs(:writable?).returns true - @public_key = stub 'public_key' - @real_key = stub 'sslkey', :public_key => @public_key + @public_key = stub 'public_key' + @real_key = stub 'sslkey', :public_key => @public_key - @key = stub 'key', :name => "myname", :content => @real_key + @key = stub 'key', :name => "myname", :content => @real_key - @request = stub 'request', :key => "myname", :instance => @key - end + @request = stub 'request', :key => "myname", :instance => @key + end - it "should save the public key when saving the private key" do - Puppet.settings.stubs(:writesub) + it "should save the public key when saving the private key" do + Puppet.settings.stubs(:writesub) - fh = mock 'filehandle' + fh = mock 'filehandle' - Puppet.settings.expects(:writesub).with(:publickeydir, @public_key_path).yields fh - @public_key.expects(:to_pem).returns "my pem" + Puppet.settings.expects(:writesub).with(:publickeydir, @public_key_path).yields fh + @public_key.expects(:to_pem).returns "my pem" - fh.expects(:print).with "my pem" + fh.expects(:print).with "my pem" - @searcher.save(@request) - end + @searcher.save(@request) + end - it "should destroy the public key when destroying the private key" do - File.stubs(:unlink).with(@private_key_path) - FileTest.stubs(:exist?).with(@private_key_path).returns true - FileTest.expects(:exist?).with(@public_key_path).returns true - File.expects(:unlink).with(@public_key_path) + it "should destroy the public key when destroying the private key" do + File.stubs(:unlink).with(@private_key_path) + FileTest.stubs(:exist?).with(@private_key_path).returns true + FileTest.expects(:exist?).with(@public_key_path).returns true + File.expects(:unlink).with(@public_key_path) - @searcher.destroy(@request) - end + @searcher.destroy(@request) + end - it "should not fail if the public key does not exist when deleting the private key" do - File.stubs(:unlink).with(@private_key_path) + it "should not fail if the public key does not exist when deleting the private key" do + File.stubs(:unlink).with(@private_key_path) - FileTest.stubs(:exist?).with(@private_key_path).returns true - FileTest.expects(:exist?).with(@public_key_path).returns false - File.expects(:unlink).with(@public_key_path).never + FileTest.stubs(:exist?).with(@private_key_path).returns true + FileTest.expects(:exist?).with(@public_key_path).returns false + File.expects(:unlink).with(@public_key_path).never - @searcher.destroy(@request) - end + @searcher.destroy(@request) end + end end |
