summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/queue
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/util/queue
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/util/queue')
-rwxr-xr-xspec/unit/util/queue/stomp_spec.rb202
1 files changed, 101 insertions, 101 deletions
diff --git a/spec/unit/util/queue/stomp_spec.rb b/spec/unit/util/queue/stomp_spec.rb
index fec179018..9f1d28448 100755
--- a/spec/unit/util/queue/stomp_spec.rb
+++ b/spec/unit/util/queue/stomp_spec.rb
@@ -4,137 +4,137 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
require 'puppet/util/queue'
describe Puppet::Util::Queue do
- confine "Missing Stomp" => Puppet.features.stomp?
+ confine "Missing Stomp" => Puppet.features.stomp?
- it 'should load :stomp client appropriately' do
- Puppet.settings.stubs(:value).returns 'faux_queue_source'
- Puppet::Util::Queue.queue_type_to_class(:stomp).name.should == 'Puppet::Util::Queue::Stomp'
- end
+ it 'should load :stomp client appropriately' do
+ Puppet.settings.stubs(:value).returns 'faux_queue_source'
+ Puppet::Util::Queue.queue_type_to_class(:stomp).name.should == 'Puppet::Util::Queue::Stomp'
+ end
end
describe 'Puppet::Util::Queue::Stomp' do
- confine "Missing Stomp" => Puppet.features.stomp?
-
- before do
- # So we make sure we never create a real client instance.
- # Otherwise we'll try to connect, and that's bad.
- Stomp::Client.stubs(:new).returns stub("client")
+ confine "Missing Stomp" => Puppet.features.stomp?
+
+ before do
+ # So we make sure we never create a real client instance.
+ # Otherwise we'll try to connect, and that's bad.
+ Stomp::Client.stubs(:new).returns stub("client")
+ end
+
+ it 'should be registered with Puppet::Util::Queue as :stomp type' do
+ Puppet::Util::Queue.queue_type_to_class(:stomp).should == Puppet::Util::Queue::Stomp
+ end
+
+ describe "when initializing" do
+ it "should create a Stomp client instance" do
+ Stomp::Client.expects(:new).returns stub("stomp_client")
+ Puppet::Util::Queue::Stomp.new
end
- it 'should be registered with Puppet::Util::Queue as :stomp type' do
- Puppet::Util::Queue.queue_type_to_class(:stomp).should == Puppet::Util::Queue::Stomp
- end
-
- describe "when initializing" do
- it "should create a Stomp client instance" do
- Stomp::Client.expects(:new).returns stub("stomp_client")
- Puppet::Util::Queue::Stomp.new
- end
-
- it "should provide helpful failures when the queue source is not a valid source" do
- # Stub rather than expect, so we can include the source in the error
- Puppet.settings.stubs(:value).with(:queue_source).returns "-----"
+ it "should provide helpful failures when the queue source is not a valid source" do
+ # Stub rather than expect, so we can include the source in the error
+ Puppet.settings.stubs(:value).with(:queue_source).returns "-----"
- lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError)
- end
+ lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError)
+ end
- it "should fail unless the queue source is a stomp URL" do
- # Stub rather than expect, so we can include the source in the error
- Puppet.settings.stubs(:value).with(:queue_source).returns "http://foo/bar"
+ it "should fail unless the queue source is a stomp URL" do
+ # Stub rather than expect, so we can include the source in the error
+ Puppet.settings.stubs(:value).with(:queue_source).returns "http://foo/bar"
- lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError)
- end
+ lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError)
+ end
- it "should fail somewhat helpfully if the Stomp client cannot be created" do
- Stomp::Client.expects(:new).raises RuntimeError
- lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError)
- end
+ it "should fail somewhat helpfully if the Stomp client cannot be created" do
+ Stomp::Client.expects(:new).raises RuntimeError
+ lambda { Puppet::Util::Queue::Stomp.new }.should raise_error(ArgumentError)
+ end
- list = %w{user password host port}
- {"user" => "myuser", "password" => "mypass", "host" => "foohost", "port" => 42}.each do |name, value|
- it "should use the #{name} from the queue source as the queueing #{name}" do
- Puppet.settings.expects(:value).with(:queue_source).returns "stomp://myuser:mypass@foohost:42/"
+ list = %w{user password host port}
+ {"user" => "myuser", "password" => "mypass", "host" => "foohost", "port" => 42}.each do |name, value|
+ it "should use the #{name} from the queue source as the queueing #{name}" do
+ Puppet.settings.expects(:value).with(:queue_source).returns "stomp://myuser:mypass@foohost:42/"
- Stomp::Client.expects(:new).with { |*args| args[list.index(name)] == value }
- Puppet::Util::Queue::Stomp.new
- end
- end
+ Stomp::Client.expects(:new).with { |*args| args[list.index(name)] == value }
+ Puppet::Util::Queue::Stomp.new
+ end
+ end
- it "should create a reliable client instance" do
- Puppet.settings.expects(:value).with(:queue_source).returns "stomp://myuser@foohost:42/"
+ it "should create a reliable client instance" do
+ Puppet.settings.expects(:value).with(:queue_source).returns "stomp://myuser@foohost:42/"
- Stomp::Client.expects(:new).with { |*args| args[4] == true }
- Puppet::Util::Queue::Stomp.new
- end
+ Stomp::Client.expects(:new).with { |*args| args[4] == true }
+ Puppet::Util::Queue::Stomp.new
end
+ end
- describe "when sending a message" do
- before do
- @client = stub 'client'
- Stomp::Client.stubs(:new).returns @client
- @queue = Puppet::Util::Queue::Stomp.new
- end
+ describe "when sending a message" do
+ before do
+ @client = stub 'client'
+ Stomp::Client.stubs(:new).returns @client
+ @queue = Puppet::Util::Queue::Stomp.new
+ end
- it "should send it to the queue client instance" do
- @client.expects(:send).with { |queue, msg, options| msg == "Smite!" }
- @queue.send_message('fooqueue', 'Smite!')
- end
+ it "should send it to the queue client instance" do
+ @client.expects(:send).with { |queue, msg, options| msg == "Smite!" }
+ @queue.send_message('fooqueue', 'Smite!')
+ end
- it "should send it to the transformed queue name" do
- @client.expects(:send).with { |queue, msg, options| queue == "/queue/fooqueue" }
- @queue.send_message('fooqueue', 'Smite!')
- end
+ it "should send it to the transformed queue name" do
+ @client.expects(:send).with { |queue, msg, options| queue == "/queue/fooqueue" }
+ @queue.send_message('fooqueue', 'Smite!')
+ end
- it "should send it as a persistent message" do
- @client.expects(:send).with { |queue, msg, options| options[:persistent] == true }
- @queue.send_message('fooqueue', 'Smite!')
- end
+ it "should send it as a persistent message" do
+ @client.expects(:send).with { |queue, msg, options| options[:persistent] == true }
+ @queue.send_message('fooqueue', 'Smite!')
end
+ end
- describe "when subscribing to a queue" do
- before do
- @client = stub 'client', :acknowledge => true
- Stomp::Client.stubs(:new).returns @client
- @queue = Puppet::Util::Queue::Stomp.new
- end
+ describe "when subscribing to a queue" do
+ before do
+ @client = stub 'client', :acknowledge => true
+ Stomp::Client.stubs(:new).returns @client
+ @queue = Puppet::Util::Queue::Stomp.new
+ end
- it "should subscribe via the queue client instance" do
- @client.expects(:subscribe)
- @queue.subscribe('fooqueue')
- end
+ it "should subscribe via the queue client instance" do
+ @client.expects(:subscribe)
+ @queue.subscribe('fooqueue')
+ end
- it "should subscribe to the transformed queue name" do
- @client.expects(:subscribe).with { |queue, options| queue == "/queue/fooqueue" }
- @queue.subscribe('fooqueue')
- end
+ it "should subscribe to the transformed queue name" do
+ @client.expects(:subscribe).with { |queue, options| queue == "/queue/fooqueue" }
+ @queue.subscribe('fooqueue')
+ end
- it "should specify that its messages should be acknowledged" do
- @client.expects(:subscribe).with { |queue, options| options[:ack] == :client }
- @queue.subscribe('fooqueue')
- end
+ it "should specify that its messages should be acknowledged" do
+ @client.expects(:subscribe).with { |queue, options| options[:ack] == :client }
+ @queue.subscribe('fooqueue')
+ end
- it "should yield the body of any received message" do
- message = mock 'message'
- message.expects(:body).returns "mybody"
+ it "should yield the body of any received message" do
+ message = mock 'message'
+ message.expects(:body).returns "mybody"
- @client.expects(:subscribe).yields(message)
+ @client.expects(:subscribe).yields(message)
- body = nil
- @queue.subscribe('fooqueue') { |b| body = b }
- body.should == "mybody"
- end
+ body = nil
+ @queue.subscribe('fooqueue') { |b| body = b }
+ body.should == "mybody"
+ end
- it "should acknowledge all successfully processed messages" do
- message = stub 'message', :body => "mybode"
+ it "should acknowledge all successfully processed messages" do
+ message = stub 'message', :body => "mybode"
- @client.stubs(:subscribe).yields(message)
- @client.expects(:acknowledge).with(message)
+ @client.stubs(:subscribe).yields(message)
+ @client.expects(:acknowledge).with(message)
- @queue.subscribe('fooqueue') { |b| "eh" }
- end
+ @queue.subscribe('fooqueue') { |b| "eh" }
end
+ end
- it 'should transform the simple queue name to "/queue/<queue_name>"' do
- Puppet::Util::Queue::Stomp.new.stompify_target('blah').should == '/queue/blah'
- end
+ it 'should transform the simple queue name to "/queue/<queue_name>"' do
+ Puppet::Util::Queue::Stomp.new.stompify_target('blah').should == '/queue/blah'
+ end
end