delivery_boy 0.2.0.beta1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.md +37 -0
- data/lib/delivery_boy/fake.rb +6 -0
- data/lib/delivery_boy/rspec.rb +10 -0
- data/lib/delivery_boy/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53868e134ceaddeaafb5f96416b3fe6a44c866dd
|
4
|
+
data.tar.gz: 3953493bbe3755d81a971b1e62c1a1a7289ad3a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c62591d732bc07cead953039d63a3fb62b00d59bdcc17dd848d859c69efbd8bca5df98c0ad47b9aa29c3fdc44698da0f16913ac5af9cc23309ced52e8e50f627
|
7
|
+
data.tar.gz: b51fc9e418556e3cdc8da29357d46a949c284d4806f7c4a047d6d424d907e2c7fd60fddbc97b5580e70974000e0620ca575f98e023a232c756a524b7f2040f27
|
data/CHANGELOG
ADDED
data/README.md
CHANGED
@@ -167,6 +167,43 @@ A PEM encoded client cert to use with an SSL connection. Must be used in combina
|
|
167
167
|
|
168
168
|
A PEM encoded client cert key to use with an SSL connection. Must be used in combination with `ssl_client_cert`.
|
169
169
|
|
170
|
+
### Testing
|
171
|
+
|
172
|
+
DeliveryBoy provides a test mode out of the box. When this mode is enabled, messages will be stored in memory rather than being sent to Kafka. If you use RSpec, enabling test mode is as easy as adding this to your spec helper:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
# spec/spec_helper.rb
|
176
|
+
require "delivery_boy/rspec"
|
177
|
+
```
|
178
|
+
|
179
|
+
Now your application can use DeliveryBoy in tests without connecting to an actual Kafka cluster. Asserting that messages have been delivered is simple:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
describe PostsController do
|
183
|
+
describe "#show" do
|
184
|
+
it "emits an event to Kafka" do
|
185
|
+
post = Post.create!(body: "hello")
|
186
|
+
|
187
|
+
get :show, id: post.id
|
188
|
+
|
189
|
+
# Use this API to extract all messages written to a Kafka topic.
|
190
|
+
messages = DeliveryBoy.testing.messages_for("post_views")
|
191
|
+
|
192
|
+
expect(messages.count).to eq 1
|
193
|
+
|
194
|
+
# In addition to #value, you can also pull out #key and #partition_key.
|
195
|
+
event = JSON.parse(messages.first.value)
|
196
|
+
|
197
|
+
expect(event["post_id"]).to eq post.id
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
```
|
202
|
+
|
203
|
+
This takes care of clearing messages after each example, as well.
|
204
|
+
|
205
|
+
If you're not using RSpec, you can easily replicate the functionality yourself. Call `DeliveryBoy.test_mode` at load time, and make sure that `DeliveryBoy.testing.clear` is called after each test.
|
206
|
+
|
170
207
|
### Instrumentation & monitoring
|
171
208
|
|
172
209
|
Since DeliveryBoy is just an opinionated API on top of ruby-kafka, you can use all the [instrumentation made available by that library](https://github.com/zendesk/ruby-kafka#instrumentation). You can also use the [existing monitoring solutions](https://github.com/zendesk/ruby-kafka#monitoring) that integrate with various monitoring services.
|
data/lib/delivery_boy/fake.rb
CHANGED
@@ -18,9 +18,15 @@ module DeliveryBoy
|
|
18
18
|
alias deliver_async! deliver
|
19
19
|
|
20
20
|
def shutdown
|
21
|
+
clear
|
22
|
+
end
|
23
|
+
|
24
|
+
# Clear all messages stored in memory.
|
25
|
+
def clear
|
21
26
|
@messages.clear
|
22
27
|
end
|
23
28
|
|
29
|
+
# Return all messages written to the specified topic.
|
24
30
|
def messages_for(topic)
|
25
31
|
@messages[topic]
|
26
32
|
end
|
data/lib/delivery_boy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delivery_boy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-kafka
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- lib/delivery_boy/fake.rb
|
106
107
|
- lib/delivery_boy/instance.rb
|
107
108
|
- lib/delivery_boy/railtie.rb
|
109
|
+
- lib/delivery_boy/rspec.rb
|
108
110
|
- lib/delivery_boy/version.rb
|
109
111
|
- lib/generators/delivery_boy/config_file.yml.erb
|
110
112
|
- lib/generators/delivery_boy/install_generator.rb
|
@@ -123,12 +125,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
125
|
version: '0'
|
124
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
127
|
requirements:
|
126
|
-
- - "
|
128
|
+
- - ">="
|
127
129
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
130
|
+
version: '0'
|
129
131
|
requirements: []
|
130
132
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.6.11
|
132
134
|
signing_key:
|
133
135
|
specification_version: 4
|
134
136
|
summary: A simple way to produce messages to Kafka from Ruby applications
|