stuffed_bunny 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjI1NmNmZDBlNzM3YTExNjFiMTIyYTY0MmYwMTA5MWI2NWUxODc5Ng==
5
+ data.tar.gz: !binary |-
6
+ NmQ4MWQyYjExOGE1YTczZjRkMDFjZDg0ZjEwOGM1YjJiMDZjZDJkNQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTkwNTIyM2NiYzk2MTZmNjA3ODg2Mjc2ODI0ZjE4ZjkwYTBlODQ4YjRlYzE4
10
+ YzhkOTY5YWMyMTQzYWNhZDNmMjZkNmRlMDljYTljNDBmMjliY2VmYTg3YTY3
11
+ NzlkNjE5N2FlOTA5NWM4MjJkMjQ2YmJjYmYyMWNkZjJjNTRhZTE=
12
+ data.tar.gz: !binary |-
13
+ NmE1Zjk4OGIzMDMxZmRmNDZhNDU1NmIxNzE3N2QxM2VlMTNmZDNlYWFkNDEy
14
+ ODNkMmY4NzAzNzJkMDRiYmYzZTBmOGQ5NTBhMDRlYzgwMTVlZjJlYmU1NTdi
15
+ YzQ4ZTJjNTgwMzQ0YjBjNDI4YWUwOTBmMDRhNmJhNjM0YjVhMjI=
data/HISTORY.md CHANGED
@@ -1,3 +1,12 @@
1
1
  # 1.0.0
2
2
 
3
3
  * Updated Queue constructor because bunny 1.1 requires a channel.
4
+
5
+ # 1.0.1
6
+
7
+ * Initialized routed_messages to be an Array to avoid nil errors in
8
+ some scenarios.
9
+
10
+ # 1.0.2
11
+
12
+ * Improved the readme by focusing on `routed_messages`.
data/README.md CHANGED
@@ -1,68 +1,56 @@
1
1
  # StuffedBunny
2
2
 
3
- Provides stubbing of the Bunny gem.
3
+ Provides stubbing of the Bunny gem to faciliate testing.
4
4
 
5
- To faciliate testing, exchanges are represented as a class-level hash. This
6
- allows all bunny instances access to the same exchanges.
5
+ A `routed_messages` array captures any publised messages on a topic exchange.
7
6
 
8
- ## Installation
9
-
10
- Add this line to your application's Gemfile:
11
-
12
- gem 'stuffed_bunny'
13
-
14
- And then execute:
15
-
16
- $ bundle
17
-
18
- Or install it yourself as:
19
-
20
- $ gem install stuffed_bunny
21
-
22
- ## Usage
23
-
24
- ### RSpec Example
7
+ ## Example Usage
25
8
 
26
9
  ```ruby
27
- # spec/spec_helper.rb
28
- require 'stuffed_bunny'
10
+ require 'stuffed_bunny' # Bunny is overriden once this is required
29
11
 
30
- RSpec.configure do |config|
12
+ class SomeTest < TestUnit::TestCase
31
13
 
32
- config.after(:each) do
33
- StuffedBunny.reset!
14
+ def setup
15
+ @bunny = Bunny::Client.new
34
16
  end
35
17
 
36
- end
37
- ```
38
-
39
- ### Minitest Example
40
-
41
- ```ruby
42
- require 'stuffed_bunny'
43
-
44
- class MiniTest::Spec
18
+ def teardown
19
+ StuffedBunny.reset! # resets the routed_messages
20
+ end
45
21
 
46
- after :each do
47
- StuffedBunny.reset!
22
+ def test_that_a_message_is_published_to_an_exchange
23
+ exchange_options = { } # set it to be a topic exchange, etc.
24
+ Bunny.run do |b|
25
+ topic_exchange = b.exchange( "a_topic_exchange", exchange_options)
26
+ publish_options = { :key => "a.routing.key" }
27
+ topic_exchange.publish("a message", publish_options)
28
+ end
29
+
30
+ routed_message = @bunny.exchanges["a_topic_exchange"].routed_messages[0]
31
+ assert_equal "a.routing.key", routed_message.key
32
+ assert_equal "a message", routed_message.message
48
33
  end
49
34
 
50
35
  end
51
36
  ```
52
37
 
53
- ### TestUnit Example
38
+ ## Installation
54
39
 
55
- ```ruby
56
- require 'stuffed_bunny'
40
+ Add this line to your application's Gemfile:
57
41
 
58
- class SomeTest < TestUnit::TestCase
42
+ group :test do
43
+ # Note that as soon as the gem is required, Bunny is overridden.
44
+ gem 'stuffed_bunny', :require => false
45
+ end
59
46
 
60
- def teardown
61
- StuffedBunny.reset!
62
- end
47
+ And then execute:
63
48
 
64
- end
65
- ```
49
+ $ bundle
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install stuffed_bunny
66
54
 
67
55
  ## Contributing
68
56
 
@@ -2,8 +2,7 @@ require 'bunny'
2
2
 
3
3
  # Overriding the Bunny gem's modules and classes.
4
4
  #
5
- # NOTE: Not everything is stubbed yet. We've only stubbed the method calls we
6
- # are using in our projects.
5
+ # NOTE: Not everything in Bunny is stubbed here. Pull requests are welcome.
7
6
  module Bunny
8
7
  def self.run(options = {})
9
8
  bunny = Bunny::Client.new(options)
@@ -42,9 +41,9 @@ module Bunny
42
41
  @client, @name = client, name
43
42
  @type = options[:type]
44
43
  end
45
-
44
+
46
45
  def routed_messages
47
- @routed_messaged ||= []
46
+ @routed_messaged ||= []
48
47
  end
49
48
 
50
49
  # To facilite testing this adds a Struct containing the data
@@ -52,8 +51,8 @@ module Bunny
52
51
  #
53
52
  # Example usage:
54
53
  # Bunny.run do |b|
55
- # topic = b.exchange("some_topic_name", MH::Exchange::OPTIONS)
56
- # options = { :key => "some.routing.key" }.merge(MH::Exchange::PUBLISH_OPTIONS)
54
+ # topic = b.exchange("some_topic_name", SOME_EXCHANGE_OPTIONS)
55
+ # options = { :key => "some.routing.key" }.merge(SOME_PUBLISH_OPTIONS)
57
56
  # topic.publish("some message", options)
58
57
  # end
59
58
  #
@@ -70,6 +69,7 @@ module Bunny
70
69
  class Queue
71
70
  def initialize(channel_or_connection, name = nil, opts = {})
72
71
  end
72
+
73
73
  def delete(*args)
74
74
  :delete_ok
75
75
  end
@@ -1,3 +1,3 @@
1
1
  module StuffedBunny
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stuffed_bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Murphy
@@ -10,12 +9,11 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2014-04-09 00:00:00.000000000 Z
12
+ date: 2016-01-08 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bunny
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
@@ -31,7 +28,6 @@ dependencies:
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ! '>='
37
33
  - !ruby/object:Gem::Version
@@ -39,7 +35,6 @@ dependencies:
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ! '>='
45
40
  - !ruby/object:Gem::Version
@@ -68,33 +63,26 @@ files:
68
63
  - stuffed_bunny.gemspec
69
64
  homepage: https://github.com/customink/stuffed_bunny
70
65
  licenses: []
66
+ metadata: {}
71
67
  post_install_message:
72
68
  rdoc_options: []
73
69
  require_paths:
74
70
  - lib
75
71
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
72
  requirements:
78
73
  - - ! '>='
79
74
  - !ruby/object:Gem::Version
80
75
  version: '0'
81
- segments:
82
- - 0
83
- hash: 1652037308544362369
84
76
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
77
  requirements:
87
78
  - - ! '>='
88
79
  - !ruby/object:Gem::Version
89
80
  version: '0'
90
- segments:
91
- - 0
92
- hash: 1652037308544362369
93
81
  requirements: []
94
82
  rubyforge_project:
95
- rubygems_version: 1.8.23
83
+ rubygems_version: 2.4.8
96
84
  signing_key:
97
- specification_version: 3
85
+ specification_version: 4
98
86
  summary: Provides stubbing of the Bunny gem.
99
87
  test_files:
100
88
  - spec/bunny_spec.rb