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/integration/network | |
| 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/integration/network')
| -rwxr-xr-x | spec/integration/network/client_spec.rb | 18 | ||||
| -rwxr-xr-x | spec/integration/network/formats_spec.rb | 154 | ||||
| -rwxr-xr-x | spec/integration/network/handler_spec.rb | 26 | ||||
| -rwxr-xr-x | spec/integration/network/server/mongrel_spec.rb | 96 | ||||
| -rwxr-xr-x | spec/integration/network/server/webrick_spec.rb | 150 |
5 files changed, 222 insertions, 222 deletions
diff --git a/spec/integration/network/client_spec.rb b/spec/integration/network/client_spec.rb index 06d145a17..4bf3ad82b 100755 --- a/spec/integration/network/client_spec.rb +++ b/spec/integration/network/client_spec.rb @@ -5,15 +5,15 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/network/client' describe Puppet::Network::Client do - %w{ca file report runner status}.each do |name| - it "should have a #{name} client" do - Puppet::Network::Client.client(name).should be_instance_of(Class) - end + %w{ca file report runner status}.each do |name| + it "should have a #{name} client" do + Puppet::Network::Client.client(name).should be_instance_of(Class) + end - [:name, :handler, :drivername].each do |data| - it "should have a #{data} value for the #{name} client" do - Puppet::Network::Client.client(name).send(data).should_not be_nil - end - end + [:name, :handler, :drivername].each do |data| + it "should have a #{data} value for the #{name} client" do + Puppet::Network::Client.client(name).send(data).should_not be_nil + end end + end end diff --git a/spec/integration/network/formats_spec.rb b/spec/integration/network/formats_spec.rb index 35e797706..e6cf28abb 100755 --- a/spec/integration/network/formats_spec.rb +++ b/spec/integration/network/formats_spec.rb @@ -5,106 +5,106 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/network/formats' class PsonIntTest - attr_accessor :string - def ==(other) - other.class == self.class and string == other.string - end - - def self.from_pson(data) - new(data[0]) - end - - def initialize(string) - @string = string - end - - def to_pson(*args) - { - 'type' => self.class.name, - 'data' => [@string] - }.to_pson(*args) - end - - def self.canonical_order(s) - s.gsub(/\{"data":\[(.*?)\],"type":"PsonIntTest"\}/,'{"type":"PsonIntTest","data":[\1]}') - end + attr_accessor :string + def ==(other) + other.class == self.class and string == other.string + end + + def self.from_pson(data) + new(data[0]) + end + + def initialize(string) + @string = string + end + + def to_pson(*args) + { + 'type' => self.class.name, + 'data' => [@string] + }.to_pson(*args) + end + + def self.canonical_order(s) + s.gsub(/\{"data":\[(.*?)\],"type":"PsonIntTest"\}/,'{"type":"PsonIntTest","data":[\1]}') + end end describe Puppet::Network::FormatHandler.format(:s) do - before do - @format = Puppet::Network::FormatHandler.format(:s) - end + before do + @format = Puppet::Network::FormatHandler.format(:s) + end - it "should support certificates" do - @format.should be_supported(Puppet::SSL::Certificate) - end + it "should support certificates" do + @format.should be_supported(Puppet::SSL::Certificate) + end - it "should not support catalogs" do - @format.should_not be_supported(Puppet::Resource::Catalog) - end + it "should not support catalogs" do + @format.should_not be_supported(Puppet::Resource::Catalog) + end end describe Puppet::Network::FormatHandler.format(:pson) do - describe "when pson is absent" do - confine "'pson' library is present" => (! Puppet.features.pson?) + describe "when pson is absent" do + confine "'pson' library is present" => (! Puppet.features.pson?) - before do - @pson = Puppet::Network::FormatHandler.format(:pson) - end + before do + @pson = Puppet::Network::FormatHandler.format(:pson) + end - it "should not be suitable" do - @pson.should_not be_suitable - end + it "should not be suitable" do + @pson.should_not be_suitable end + end - describe "when pson is available" do - confine "Missing 'pson' library" => Puppet.features.pson? + describe "when pson is available" do + confine "Missing 'pson' library" => Puppet.features.pson? - before do - @pson = Puppet::Network::FormatHandler.format(:pson) - end + before do + @pson = Puppet::Network::FormatHandler.format(:pson) + end - it "should be able to render an instance to pson" do - instance = PsonIntTest.new("foo") - PsonIntTest.canonical_order(@pson.render(instance)).should == PsonIntTest.canonical_order('{"type":"PsonIntTest","data":["foo"]}' ) - end + it "should be able to render an instance to pson" do + instance = PsonIntTest.new("foo") + PsonIntTest.canonical_order(@pson.render(instance)).should == PsonIntTest.canonical_order('{"type":"PsonIntTest","data":["foo"]}' ) + end - it "should be able to render arrays to pson" do - @pson.render([1,2]).should == '[1,2]' - end + it "should be able to render arrays to pson" do + @pson.render([1,2]).should == '[1,2]' + end - it "should be able to render arrays containing hashes to pson" do - @pson.render([{"one"=>1},{"two"=>2}]).should == '[{"one":1},{"two":2}]' - end + it "should be able to render arrays containing hashes to pson" do + @pson.render([{"one"=>1},{"two"=>2}]).should == '[{"one":1},{"two":2}]' + end - it "should be able to render multiple instances to pson" do - Puppet.features.add(:pson, :libs => ["pson"]) + it "should be able to render multiple instances to pson" do + Puppet.features.add(:pson, :libs => ["pson"]) - one = PsonIntTest.new("one") - two = PsonIntTest.new("two") + one = PsonIntTest.new("one") + two = PsonIntTest.new("two") - PsonIntTest.canonical_order(@pson.render([one,two])).should == PsonIntTest.canonical_order('[{"type":"PsonIntTest","data":["one"]},{"type":"PsonIntTest","data":["two"]}]') - end + PsonIntTest.canonical_order(@pson.render([one,two])).should == PsonIntTest.canonical_order('[{"type":"PsonIntTest","data":["one"]},{"type":"PsonIntTest","data":["two"]}]') + end - it "should be able to intern pson into an instance" do - @pson.intern(PsonIntTest, '{"type":"PsonIntTest","data":["foo"]}').should == PsonIntTest.new("foo") - end + it "should be able to intern pson into an instance" do + @pson.intern(PsonIntTest, '{"type":"PsonIntTest","data":["foo"]}').should == PsonIntTest.new("foo") + end - it "should be able to intern pson with no class information into an instance" do - @pson.intern(PsonIntTest, '["foo"]').should == PsonIntTest.new("foo") - end + it "should be able to intern pson with no class information into an instance" do + @pson.intern(PsonIntTest, '["foo"]').should == PsonIntTest.new("foo") + end - it "should be able to intern multiple instances from pson" do - @pson.intern_multiple(PsonIntTest, '[{"type": "PsonIntTest", "data": ["one"]},{"type": "PsonIntTest", "data": ["two"]}]').should == [ - PsonIntTest.new("one"), PsonIntTest.new("two") - ] - end + it "should be able to intern multiple instances from pson" do + @pson.intern_multiple(PsonIntTest, '[{"type": "PsonIntTest", "data": ["one"]},{"type": "PsonIntTest", "data": ["two"]}]').should == [ + PsonIntTest.new("one"), PsonIntTest.new("two") + ] + end - it "should be able to intern multiple instances from pson with no class information" do - @pson.intern_multiple(PsonIntTest, '[["one"],["two"]]').should == [ - PsonIntTest.new("one"), PsonIntTest.new("two") - ] - end + it "should be able to intern multiple instances from pson with no class information" do + @pson.intern_multiple(PsonIntTest, '[["one"],["two"]]').should == [ + PsonIntTest.new("one"), PsonIntTest.new("two") + ] end + end end diff --git a/spec/integration/network/handler_spec.rb b/spec/integration/network/handler_spec.rb index 1c2e60549..021f1cedb 100755 --- a/spec/integration/network/handler_spec.rb +++ b/spec/integration/network/handler_spec.rb @@ -5,21 +5,21 @@ require File.dirname(__FILE__) + '/../../spec_helper' require 'puppet/network/client' describe Puppet::Network::Handler do - %w{ca filebucket fileserver master report runner status}.each do |name| - it "should have a #{name} client" do - Puppet::Network::Handler.handler(name).should be_instance_of(Class) - end + %w{ca filebucket fileserver master report runner status}.each do |name| + it "should have a #{name} client" do + Puppet::Network::Handler.handler(name).should be_instance_of(Class) + end - it "should have a name" do - Puppet::Network::Handler.handler(name).name.to_s.downcase.should == name.to_s.downcase - end + it "should have a name" do + Puppet::Network::Handler.handler(name).name.to_s.downcase.should == name.to_s.downcase + end - it "should have an interface" do - Puppet::Network::Handler.handler(name).interface.should_not be_nil - end + it "should have an interface" do + Puppet::Network::Handler.handler(name).interface.should_not be_nil + end - it "should have a prefix for the interface" do - Puppet::Network::Handler.handler(name).interface.prefix.should_not be_nil - end + it "should have a prefix for the interface" do + Puppet::Network::Handler.handler(name).interface.prefix.should_not be_nil end + end end diff --git a/spec/integration/network/server/mongrel_spec.rb b/spec/integration/network/server/mongrel_spec.rb index 1365fbd41..cc90773e6 100755 --- a/spec/integration/network/server/mongrel_spec.rb +++ b/spec/integration/network/server/mongrel_spec.rb @@ -5,62 +5,62 @@ require 'puppet/network/server' require 'socket' describe Puppet::Network::Server do - describe "when using mongrel" do - confine "Mongrel is not available" => Puppet.features.mongrel? + describe "when using mongrel" do + confine "Mongrel is not available" => Puppet.features.mongrel? - before :each do - Puppet[:servertype] = 'mongrel' - Puppet[:server] = '127.0.0.1' - @params = { :port => 34346, :handlers => [ :node ] } - @server = Puppet::Network::Server.new(@params) - end + before :each do + Puppet[:servertype] = 'mongrel' + Puppet[:server] = '127.0.0.1' + @params = { :port => 34346, :handlers => [ :node ] } + @server = Puppet::Network::Server.new(@params) + end - after { Puppet.settings.clear } + after { Puppet.settings.clear } - describe "before listening" do - it "should not be reachable at the specified address and port" do - lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED) - end - end + describe "before listening" do + it "should not be reachable at the specified address and port" do + lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED) + end + end - describe "when listening" do - it "should be reachable on the specified address and port" do - @server.listen - lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error - end + describe "when listening" do + it "should be reachable on the specified address and port" do + @server.listen + lambda { TCPSocket.new('127.0.0.1', 34346) }.should_not raise_error + end - it "should default to '127.0.0.1' as its bind address" do - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening - @server.send(:http_server).expects(:listen).with { |args| args[:address] == "127.0.0.1" } - @server.listen - end + it "should default to '127.0.0.1' as its bind address" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "127.0.0.1" } + @server.listen + end - it "should use any specified bind address" do - Puppet[:bindaddress] = "0.0.0.0" - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening - @server.send(:http_server).expects(:listen).with { |args| args[:address] == "0.0.0.0" } - @server.listen - end + it "should use any specified bind address" do + Puppet[:bindaddress] = "0.0.0.0" + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "0.0.0.0" } + @server.listen + end - it "should not allow multiple servers to listen on the same address and port" do - @server.listen - @server2 = Puppet::Network::Server.new(@params) - lambda { @server2.listen }.should raise_error - end - end + it "should not allow multiple servers to listen on the same address and port" do + @server.listen + @server2 = Puppet::Network::Server.new(@params) + lambda { @server2.listen }.should raise_error + end + end - describe "after unlistening" do - it "should not be reachable on the port and address assigned" do - @server.listen - @server.unlisten - lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED) - end - end + describe "after unlistening" do + it "should not be reachable on the port and address assigned" do + @server.listen + @server.unlisten + lambda { TCPSocket.new('127.0.0.1', 34346) }.should raise_error(Errno::ECONNREFUSED) + end + end - after :each do - @server.unlisten if @server.listening? - end + after :each do + @server.unlisten if @server.listening? end + end end diff --git a/spec/integration/network/server/webrick_spec.rb b/spec/integration/network/server/webrick_spec.rb index 50994f119..2809df780 100755 --- a/spec/integration/network/server/webrick_spec.rb +++ b/spec/integration/network/server/webrick_spec.rb @@ -6,80 +6,80 @@ require 'puppet/ssl/certificate_authority' require 'socket' describe Puppet::Network::Server do - describe "when using webrick" do - before :each do - Puppet[:servertype] = 'webrick' - Puppet[:server] = '127.0.0.1' - @params = { :port => 34343, :handlers => [ :node ], :xmlrpc_handlers => [ :status ] } - - # Get a safe temporary file - @tmpfile = Tempfile.new("webrick_integration_testing") - @dir = @tmpfile.path + "_dir" - - Puppet.settings[:confdir] = @dir - Puppet.settings[:vardir] = @dir - - Puppet::SSL::Host.ca_location = :local - - ca = Puppet::SSL::CertificateAuthority.new - ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname]) - end - - after do - @tmpfile.delete - Puppet.settings.clear - - system("rm -rf #{@dir}") - - Puppet::Util::Cacher.expire - end - - describe "before listening" do - it "should not be reachable at the specified address and port" do - lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error - end - end - - describe "when listening" do - it "should be reachable on the specified address and port" do - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.listen - lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error - end - - it "should default to '0.0.0.0' as its bind address" do - Puppet.settings.clear - Puppet[:servertype] = 'webrick' - Puppet[:bindaddress].should == '0.0.0.0' - end - - it "should use any specified bind address" do - Puppet[:bindaddress] = "127.0.0.1" - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening - @server.send(:http_server).expects(:listen).with { |args| args[:address] == "127.0.0.1" } - @server.listen - end - - it "should not allow multiple servers to listen on the same address and port" do - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.listen - @server2 = Puppet::Network::Server.new(@params.merge(:port => 34343)) - lambda { @server2.listen }.should raise_error - end - - after :each do - @server.unlisten if @server && @server.listening? - end - end - - describe "after unlistening" do - it "should not be reachable on the port and address assigned" do - @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) - @server.listen - @server.unlisten - lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error(Errno::ECONNREFUSED) - end - end + describe "when using webrick" do + before :each do + Puppet[:servertype] = 'webrick' + Puppet[:server] = '127.0.0.1' + @params = { :port => 34343, :handlers => [ :node ], :xmlrpc_handlers => [ :status ] } + + # Get a safe temporary file + @tmpfile = Tempfile.new("webrick_integration_testing") + @dir = @tmpfile.path + "_dir" + + Puppet.settings[:confdir] = @dir + Puppet.settings[:vardir] = @dir + + Puppet::SSL::Host.ca_location = :local + + ca = Puppet::SSL::CertificateAuthority.new + ca.generate(Puppet[:certname]) unless Puppet::SSL::Certificate.find(Puppet[:certname]) + end + + after do + @tmpfile.delete + Puppet.settings.clear + + system("rm -rf #{@dir}") + + Puppet::Util::Cacher.expire + end + + describe "before listening" do + it "should not be reachable at the specified address and port" do + lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error + end + end + + describe "when listening" do + it "should be reachable on the specified address and port" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.listen + lambda { TCPSocket.new('127.0.0.1', 34343) }.should_not raise_error + end + + it "should default to '0.0.0.0' as its bind address" do + Puppet.settings.clear + Puppet[:servertype] = 'webrick' + Puppet[:bindaddress].should == '0.0.0.0' + end + + it "should use any specified bind address" do + Puppet[:bindaddress] = "127.0.0.1" + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.stubs(:unlisten) # we're breaking listening internally, so we have to keep it from unlistening + @server.send(:http_server).expects(:listen).with { |args| args[:address] == "127.0.0.1" } + @server.listen + end + + it "should not allow multiple servers to listen on the same address and port" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.listen + @server2 = Puppet::Network::Server.new(@params.merge(:port => 34343)) + lambda { @server2.listen }.should raise_error + end + + after :each do + @server.unlisten if @server && @server.listening? + end + end + + describe "after unlistening" do + it "should not be reachable on the port and address assigned" do + @server = Puppet::Network::Server.new(@params.merge(:port => 34343)) + @server.listen + @server.unlisten + lambda { TCPSocket.new('127.0.0.1', 34343) }.should raise_error(Errno::ECONNREFUSED) + end end + end end |
