stuffed_bunny 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ desc 'Default: run minispec specs.'
5
+ task default: :test
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << "lib"
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.verbose = true
11
+ end
@@ -2,10 +2,8 @@ require 'stuffed_bunny/version'
2
2
  require 'stuffed_bunny/bunny_overrides'
3
3
 
4
4
  module StuffedBunny
5
-
6
5
  # Call this in a test's setup method to stub the Bunny gem.
7
6
  def self.reset!
8
7
  Bunny.reset_exchanges
9
8
  end
10
-
11
9
  end
@@ -29,6 +29,10 @@ module Bunny
29
29
  def exchanges
30
30
  @@exchanges
31
31
  end
32
+
33
+ def queue(queue_name, options=nil)
34
+ Bunny::Queue.new
35
+ end
32
36
  end
33
37
 
34
38
  class Exchange
@@ -59,4 +63,10 @@ module Bunny
59
63
  @routed_messages << Struct.new(:message, :key).new(data, options[:key])
60
64
  end
61
65
  end
62
- end
66
+
67
+ class Queue
68
+ def delete(*args)
69
+ :delete_ok
70
+ end
71
+ end
72
+ end
@@ -1,3 +1,3 @@
1
1
  module StuffedBunny
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -0,0 +1,35 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Bunny do
4
+ before do
5
+ @client = Bunny::Client.new
6
+ end
7
+
8
+ describe 'on .reset_exchanges' do
9
+ before do
10
+ @client.exchange(:test_exchange)
11
+ end
12
+
13
+ it 'resets them back to an empty hash' do
14
+ Bunny.reset_exchanges
15
+ @client.exchanges.must_be_empty
16
+ end
17
+ end
18
+
19
+ describe 'on .reset!' do
20
+ before do
21
+ @client.exchange(:test_exchange)
22
+ end
23
+
24
+ it 'resets them back to an empty hash' do
25
+ StuffedBunny.reset!
26
+ @client.exchanges.must_be_empty
27
+ end
28
+ end
29
+
30
+ describe 'on .queue' do
31
+ it 'returns a new queue with default options' do
32
+ @client.queue( "queue", passive: true ).must_be_instance_of Bunny::Queue
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Bunny::Client do
4
+ before do
5
+ @client = Bunny::Client.new
6
+ end
7
+
8
+ describe 'on .new' do
9
+ it 'returns a new Bunny::Client' do
10
+ @client.must_be_kind_of Bunny::Client
11
+ end
12
+ end
13
+
14
+ describe 'on #exchange' do
15
+ it 'adds a new Exchange with the given name' do
16
+ @client.exchange(:test_exchange)
17
+ exchanges = @client.class.class_variable_get(:@@exchanges)
18
+ exchanges[:test_exchange].wont_be_nil
19
+ end
20
+ end
21
+
22
+ describe 'on #exchanges' do
23
+ it 'returns the exchanges class variable' do
24
+ @client.exchanges.must_equal @client.class.class_variable_get(:@@exchanges)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Bunny::Exchange do
4
+ before do
5
+ client = Bunny::Client.new
6
+ @exchange = Bunny::Exchange.new(client, :test_name)
7
+ end
8
+
9
+
10
+ describe 'on .new' do
11
+ it 'should have expected accessors' do
12
+ [:client, :type, :name, :routed_messages].each do |accessor|
13
+ @exchange.must_respond_to accessor
14
+ end
15
+ end
16
+
17
+ it 'initialize routed_messages to an array' do
18
+ @exchange.routed_messages.must_be_kind_of Array
19
+ end
20
+ end
21
+
22
+ describe 'after #publish' do
23
+ before do
24
+ @data = "some data"
25
+ @options = { key: "some_routing_key" }
26
+ @exchange.publish(@data, @options)
27
+ @routed_message = @exchange.routed_messages.first
28
+ end
29
+
30
+ it 'should have a routed message that exposes the data' do
31
+ @routed_message.message.must_equal @data
32
+ end
33
+
34
+ it 'should have a routed message that exposes the key' do
35
+ @routed_message.key.must_equal @options[:key]
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Bunny::Queue do
4
+ before do
5
+ @queue = Bunny::Queue.new
6
+ end
7
+
8
+ describe 'on .delete' do
9
+ it 'return the :delete_ok symbol' do
10
+ @queue.delete.must_equal :delete_ok
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ ENV['RACK_ENV'] ||= 'test'
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+
6
+ require 'bundler/setup'
7
+ require 'minitest/autorun'
8
+ require 'minitest/reporters'
9
+ require 'stuffed_bunny'
10
+
11
+ MiniTest::Reporters.use! MiniTest::Reporters::ProgressReporter.new
@@ -16,4 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency 'bunny', '~> 0.8'
21
+ gem.add_development_dependency 'minitest-reporters'
22
+ gem.add_development_dependency 'rake', '10.0.3'
19
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stuffed_bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,8 +10,56 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-06 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2013-03-06 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bunny
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '0.8'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '0.8'
31
+ - !ruby/object:Gem::Dependency
32
+ name: minitest-reporters
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 10.0.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 10.0.3
15
63
  description: Provides stubbing of the Bunny gem.
16
64
  email:
17
65
  - cmurphy@customink.com
@@ -27,6 +75,11 @@ files:
27
75
  - lib/stuffed_bunny.rb
28
76
  - lib/stuffed_bunny/bunny_overrides.rb
29
77
  - lib/stuffed_bunny/version.rb
78
+ - spec/bunny_spec.rb
79
+ - spec/client_spec.rb
80
+ - spec/exchanges_spec.rb
81
+ - spec/queue_spec.rb
82
+ - spec/spec_helper.rb
30
83
  - stuffed_bunny.gemspec
31
84
  homepage: https://github.com/customink/stuffed_bunny
32
85
  licenses: []
@@ -40,16 +93,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
40
93
  - - ! '>='
41
94
  - !ruby/object:Gem::Version
42
95
  version: '0'
96
+ segments:
97
+ - 0
98
+ hash: 1986827251272161089
43
99
  required_rubygems_version: !ruby/object:Gem::Requirement
44
100
  none: false
45
101
  requirements:
46
102
  - - ! '>='
47
103
  - !ruby/object:Gem::Version
48
104
  version: '0'
105
+ segments:
106
+ - 0
107
+ hash: 1986827251272161089
49
108
  requirements: []
50
109
  rubyforge_project:
51
110
  rubygems_version: 1.8.24
52
111
  signing_key:
53
112
  specification_version: 3
54
113
  summary: Provides stubbing of the Bunny gem.
55
- test_files: []
114
+ test_files:
115
+ - spec/bunny_spec.rb
116
+ - spec/client_spec.rb
117
+ - spec/exchanges_spec.rb
118
+ - spec/queue_spec.rb
119
+ - spec/spec_helper.rb