schoefmax-warren 0.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/spec.opts ADDED
@@ -0,0 +1,3 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__) + "/../lib/warren")
2
+
3
+ # Hacky and I hate it, but needed to
4
+ # change constants in tests
5
+ # from http://is.gd/12JVp
6
+ def silently(&block)
7
+ warn_level = $VERBOSE
8
+ $VERBOSE = nil
9
+ result = block.call
10
+ $VERBOSE = warn_level
11
+ result
12
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require "#{File.dirname(__FILE__)}/../../../lib/warren/adapters/test_adapter.rb"
3
+
4
+ describe TestAdapter do
5
+
6
+ before(:all) do
7
+ @file_name = "#{WARREN_ROOT}/tmp/warren.txt"
8
+ end
9
+
10
+ it "should return true from publish without a tmp file" do
11
+ TestAdapter.publish(:queue_name, :payload).should == true
12
+ end
13
+
14
+ it "should return true from publish with a tmp file which doesn't say \"FAIL\"" do
15
+ File.should_receive(:exists?).with(@file_name).and_return(true)
16
+ File.should_receive(:read).with(@file_name, 4).and_return("blah")
17
+
18
+ TestAdapter.publish(:queue_name, :payload).should == true
19
+ end
20
+
21
+ it "should raise an error when tmp file exists and says \"FAIL\"" do
22
+ File.should_receive(:exists?).with(@file_name).and_return(true)
23
+ File.should_receive(:read).with(@file_name, 4).and_return("FAIL")
24
+
25
+ lambda { TestAdapter.publish(:queue_name, :payload) }.
26
+ should raise_error(TestAdapter::ConnectionFailed)
27
+ end
28
+
29
+ end
@@ -0,0 +1,122 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Warren::Connection do
4
+
5
+ before(:each) do
6
+ setup_adapter
7
+ end
8
+
9
+ it "should read from warren.yml" do
10
+ setup_config_file
11
+
12
+ Warren::Connection.new
13
+ end
14
+
15
+ it "should read from an arbitrary file" do
16
+ File.should_receive(:exists?).with("my_awesome_config.yml").and_return(true)
17
+ YAML.should_receive(:load_file).with("my_awesome_config.yml").and_return({"development" => {}})
18
+
19
+ Warren::Connection.new("my_awesome_config.yml")
20
+ end
21
+
22
+ describe "parsing config with file" do
23
+
24
+ before do
25
+ setup_config_file
26
+ end
27
+
28
+ it "should parse the right config out" do
29
+ conn = Warren::Connection.new
30
+ WARREN_ENV.should == "development"
31
+ conn.instance_variable_get("@options").should == {
32
+ :user => "rspec",
33
+ :pass => "password",
34
+ :host => "localhost",
35
+ :logging => false,
36
+ }
37
+ end
38
+
39
+ it "should raise if no details for current environment" do
40
+ silently { WARREN_ENV = "rspec" }
41
+
42
+ lambda { Warren::Connection.new }.
43
+ should raise_error(
44
+ Warren::Connection::InvalidConnectionDetails,
45
+ "No details for current environment 'rspec'"
46
+ )
47
+
48
+ silently { WARREN_ENV = "development" }
49
+ end
50
+
51
+ it "should symbolize keys in a hash" do
52
+ conn = Warren::Connection.new
53
+ hash = {"one" => "two", "three" => {"four" => 7}, :five => "six"}
54
+ conn.send(:symbolize_keys, hash).should == {
55
+ :one => "two",
56
+ :three => {:four => 7},
57
+ :five => "six"
58
+ }
59
+ end
60
+
61
+ it "should raise if no adapter set to check against" do
62
+ Warren::Queue.adapter = nil
63
+ lambda { Warren::Connection.new }.
64
+ should raise_error(Warren::Queue::NoAdapterSet)
65
+ end
66
+
67
+ it "should successfully check against adapter" do
68
+ _adapter = mock 'queue', :check_connection_details => true
69
+ _adapter.should_receive(:check_connection_details)
70
+ Warren::Queue.adapter = _adapter
71
+
72
+ Warren::Connection.new
73
+ end
74
+
75
+ it "should raise errors for missing connection details" do
76
+ _adapter = stub 'queue', :check_connection_details => ["one", "two"]
77
+
78
+ Warren::Connection.new
79
+ end
80
+
81
+ it "should raise errors for other prerequisits in the adapter" do
82
+ Adapter = Class.new(Warren::Queue) do
83
+ def self.check_connection_details params
84
+ raise Warren::Connection::InvalidConnectionDetails, "Missing prerequisites"
85
+ end
86
+ end
87
+
88
+ lambda { Warren::Connection.new }.
89
+ should raise_error(Warren::Connection::InvalidConnectionDetails, "Missing prerequisites")
90
+ end
91
+
92
+ end
93
+
94
+ def setup_config_file
95
+ config_file = "#{File.dirname($0)}/config/warren.yml"
96
+ File.should_receive(:exists?).with(config_file).and_return(true)
97
+ YAML.should_receive(:load_file).with(config_file).and_return(yaml_data)
98
+ end
99
+
100
+ def setup_adapter
101
+ _adapter = stub 'queue'
102
+ Warren::Queue.adapter = _adapter
103
+ end
104
+
105
+ def yaml_data
106
+ {
107
+ "development" => {
108
+ "host" => "localhost",
109
+ "user" => "rspec",
110
+ "pass" => "password",
111
+ "logging" => false
112
+ },
113
+ "test" => {
114
+ "host" => "localhost-test",
115
+ "user" => "rspec-test",
116
+ "pass" => "password-test",
117
+ "logging" => true
118
+ }
119
+ }
120
+ end
121
+
122
+ end
@@ -0,0 +1,73 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Warren::Queue do
4
+
5
+ describe "connection" do
6
+
7
+ before(:all) do
8
+ @conn = stub 'connection'
9
+ end
10
+
11
+ it "should create a new Warren::Connection if one doesn't exist" do
12
+ Warren::Connection.should_receive(:new).and_return(@conn)
13
+
14
+ Warren::Queue.connection.should == @conn
15
+ end
16
+
17
+ it "should only create a connection once" do
18
+ # Already created the connection object in the first it
19
+ Warren::Connection.should_not_receive(:new)
20
+
21
+ Warren::Queue.connection.should == @conn
22
+ Warren::Queue.connection.should == @conn
23
+ end
24
+ end
25
+
26
+ describe "adapter" do
27
+
28
+ before(:each) do
29
+ @adapter = mock 'adapter', :publish => "publish", :subscribe => "subscribe"
30
+ Warren::Queue.adapter = @adapter
31
+ end
32
+
33
+ it "should have an adapter set" do
34
+ Warren::Queue.adapter.should == @adapter
35
+ end
36
+
37
+ it "should pass publish through to the adapter" do
38
+ @adapter.should_receive(:publish)
39
+ Warren::Queue.publish.should == "publish"
40
+ end
41
+
42
+ it "should pass arguments through to adapter#publish" do
43
+ @adapter.should_receive(:publish).with("foo", "bar")
44
+
45
+ Warren::Queue.publish("foo", "bar").should == "publish"
46
+ end
47
+
48
+ it "should pass a block through to adapter#publish" do
49
+ block = lambda { true }
50
+ @adapter.should_receive(:publish).with("foo", "bar", block)
51
+
52
+ Warren::Queue.publish("foo", "bar", block).should == "publish"
53
+ end
54
+
55
+ it "should pass subscribe through to the adapter" do
56
+ @adapter.should_receive(:subscribe)
57
+ Warren::Queue.subscribe.should == "subscribe"
58
+ end
59
+
60
+ it "should pass arguments through to adapter#subscribe" do
61
+ @adapter.should_receive(:subscribe).with("foo", "bar")
62
+
63
+ Warren::Queue.subscribe("foo", "bar").should == "subscribe"
64
+ end
65
+
66
+ it "should pass a block through to adapter#subscribe" do
67
+ block = lambda { true }
68
+ @adapter.should_receive(:subscribe).with("foo", "bar", block)
69
+
70
+ Warren::Queue.subscribe("foo", "bar", block).should == "subscribe"
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Warren do
4
+
5
+ it "should have a default environment" do
6
+ WARREN_ENV.should == "development"
7
+ end
8
+
9
+ end
data/tasks/rdoc.rake ADDED
@@ -0,0 +1,7 @@
1
+ require "rake/rdoctask"
2
+
3
+ Rake::RDocTask.new do |rd|
4
+ rd.main = "lib/warren.rb"
5
+ rd.rdoc_files.include("lib/**/*.rb")
6
+ rd.rdoc_dir = "doc"
7
+ end
data/tasks/rspec.rake ADDED
@@ -0,0 +1,24 @@
1
+ # Borrowed from http://github.com/rsim/ruby-plsql/tree/master/tasks/rspec.rake
2
+ # Github++
3
+ begin
4
+ require "spec"
5
+ rescue LoadError
6
+ require "rubygems"
7
+ require "spec"
8
+ end
9
+
10
+ begin
11
+ require "spec/rake/spectask"
12
+ rescue LoadError
13
+ puts <<-EOS
14
+ To use rspec for testing you must install rspec gem:
15
+ [sudo] gem install rspec
16
+ EOS
17
+ exit(0)
18
+ end
19
+
20
+ desc "Run the specs under spec/*"
21
+ Spec::Rake::SpecTask.new do |t|
22
+ t.spec_opts = ["--options", "spec/spec.opts"]
23
+ t.spec_files = FileList["spec/**/*_spec.rb"]
24
+ end
data/warren.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{warren}
5
+ s.version = "0.8.8"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Caius Durling, David Smalley"]
9
+ s.date = %q{2009-07-03}
10
+ s.description = %q{Library for pushing messages onto and off RabbitMQ queues}
11
+ s.email = %q{support@brightbox.co.uk}
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/warren/adapters/amqp_adapter.rb", "lib/warren/adapters/bunny_adapter.rb", "lib/warren/adapters/dummy_adapter.rb", "lib/warren/adapters/test_adapter.rb", "lib/warren/connection.rb", "lib/warren/filters/shared_secret.rb", "lib/warren/filters/yaml.rb", "lib/warren/message_filter.rb", "lib/warren/queue.rb", "lib/warren.rb", "LICENSE", "tasks/rdoc.rake", "tasks/rspec.rake"]
13
+ s.files = ["CHANGELOG", "examples/authed/receiver.rb", "examples/authed/secret.rb", "examples/authed/sender.rb", "examples/simple/amqp_mass_sender.rb", "examples/simple/amqp_receiver.rb", "examples/simple/amqp_sender.rb", "examples/simple/bunny_receiver.rb", "examples/simple/bunny_sender.rb", "lib/warren/adapters/amqp_adapter.rb", "lib/warren/adapters/bunny_adapter.rb", "lib/warren/adapters/dummy_adapter.rb", "lib/warren/adapters/test_adapter.rb", "lib/warren/connection.rb", "lib/warren/filters/shared_secret.rb", "lib/warren/filters/yaml.rb", "lib/warren/message_filter.rb", "lib/warren/queue.rb", "lib/warren.rb", "LICENSE", "Manifest", "Rakefile", "readme.rdoc", "spec/spec.opts", "spec/spec_helper.rb", "spec/warren/adapters/test_adapter_spec.rb", "spec/warren/connection_spec.rb", "spec/warren/queue_spec.rb", "spec/warren/warren_spec.rb", "tasks/rdoc.rake", "tasks/rspec.rake", "warren.gemspec"]
14
+ s.homepage = %q{http://github.com/brightbox/warren}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Warren", "--main", "readme.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{warren}
18
+ s.rubygems_version = %q{1.3.4}
19
+ s.summary = %q{Library for pushing messages onto and off RabbitMQ queues}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<amqp>, [">= 0.6.0"])
27
+ else
28
+ s.add_dependency(%q<amqp>, [">= 0.6.0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<amqp>, [">= 0.6.0"])
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: schoefmax-warren
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.8
5
+ platform: ruby
6
+ authors:
7
+ - Caius Durling, David Smalley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-03 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: amqp
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.6.0
24
+ version:
25
+ description: Library for pushing messages onto and off RabbitMQ queues
26
+ email: support@brightbox.co.uk
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - CHANGELOG
33
+ - lib/warren/adapters/amqp_adapter.rb
34
+ - lib/warren/adapters/bunny_adapter.rb
35
+ - lib/warren/adapters/dummy_adapter.rb
36
+ - lib/warren/adapters/test_adapter.rb
37
+ - lib/warren/connection.rb
38
+ - lib/warren/filters/shared_secret.rb
39
+ - lib/warren/filters/yaml.rb
40
+ - lib/warren/message_filter.rb
41
+ - lib/warren/queue.rb
42
+ - lib/warren.rb
43
+ - LICENSE
44
+ - tasks/rdoc.rake
45
+ - tasks/rspec.rake
46
+ files:
47
+ - CHANGELOG
48
+ - examples/authed/receiver.rb
49
+ - examples/authed/secret.rb
50
+ - examples/authed/sender.rb
51
+ - examples/simple/amqp_mass_sender.rb
52
+ - examples/simple/amqp_receiver.rb
53
+ - examples/simple/amqp_sender.rb
54
+ - examples/simple/bunny_receiver.rb
55
+ - examples/simple/bunny_sender.rb
56
+ - lib/warren/adapters/amqp_adapter.rb
57
+ - lib/warren/adapters/bunny_adapter.rb
58
+ - lib/warren/adapters/dummy_adapter.rb
59
+ - lib/warren/adapters/test_adapter.rb
60
+ - lib/warren/connection.rb
61
+ - lib/warren/filters/shared_secret.rb
62
+ - lib/warren/filters/yaml.rb
63
+ - lib/warren/message_filter.rb
64
+ - lib/warren/queue.rb
65
+ - lib/warren.rb
66
+ - LICENSE
67
+ - Manifest
68
+ - Rakefile
69
+ - readme.rdoc
70
+ - spec/spec.opts
71
+ - spec/spec_helper.rb
72
+ - spec/warren/adapters/test_adapter_spec.rb
73
+ - spec/warren/connection_spec.rb
74
+ - spec/warren/queue_spec.rb
75
+ - spec/warren/warren_spec.rb
76
+ - tasks/rdoc.rake
77
+ - tasks/rspec.rake
78
+ - warren.gemspec
79
+ has_rdoc: false
80
+ homepage: http://github.com/brightbox/warren
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --line-numbers
84
+ - --inline-source
85
+ - --title
86
+ - Warren
87
+ - --main
88
+ - readme.rdoc
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "1.2"
102
+ version:
103
+ requirements: []
104
+
105
+ rubyforge_project: warren
106
+ rubygems_version: 1.2.0
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Library for pushing messages onto and off RabbitMQ queues
110
+ test_files: []
111
+