amqp-spec 0.3.0 → 0.3.1
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/HISTORY +4 -0
- data/README.rdoc +13 -11
- data/VERSION +1 -1
- data/lib/amqp-spec/evented_example.rb +6 -4
- data/lib/amqp-spec/rspec.rb +3 -0
- metadata +20 -5
data/HISTORY
CHANGED
data/README.rdoc
CHANGED
@@ -33,7 +33,7 @@ interactions, but still specify some event-based expectations.
|
|
33
33
|
==Rspec
|
34
34
|
|
35
35
|
There are several ways to use amqp-spec. To use it as a helper, include AMQP::SpecHelper
|
36
|
-
in your describe block. You then use either
|
36
|
+
in your describe block. You then use either #amqp or #em methods to wrap your evented
|
37
37
|
test code. Inside the amqp/em block, you must call #done after your expectations. Everything
|
38
38
|
works normally otherwise. You can set default_timeout and default_options to avoid manually
|
39
39
|
setting AMQP options for each example. However, if you DO supply options to #amqp method
|
@@ -44,8 +44,9 @@ its nested groups, unconnected example groups DO NOT share defaults. Please note
|
|
44
44
|
this is different from EM-Spec where default_timeout is effectively a global setting.
|
45
45
|
|
46
46
|
In order to setup/teardown EM state before/after your examples, you'll need to use
|
47
|
-
*em_before
|
47
|
+
*em_before* and *em_after* hooks. These hooks are similar to standard RSpec's
|
48
48
|
*before/after* hooks but run inside the EM event loop before/after your example block.
|
49
|
+
If you are using
|
49
50
|
|
50
51
|
require "amqp-spec/rspec"
|
51
52
|
|
@@ -90,14 +91,14 @@ In order to setup/teardown EM state before/after your examples, you'll need to u
|
|
90
91
|
|
91
92
|
Another option is to include AMQP::Spec in your describe block. This will patch Rspec so
|
92
93
|
that all of your examples run inside an amqp block automatically. A word of caution about
|
93
|
-
*before
|
94
|
-
will run in its separate EM loop that you'll need to shut down either manually (done) or
|
94
|
+
*before*/*after* hooks in your example groups including AMQP::Spec. Each of these hooks
|
95
|
+
will run in its separate EM loop that you'll need to shut down either manually (#done) or
|
95
96
|
via timeout. Essentially, this means that any EM-related state that you'd like to set up or
|
96
97
|
tear down using these hooks will be lost as example itself will run in a different EM loop.
|
97
98
|
|
98
99
|
In short, you should avoid using *before/after* if you include AMQP::Spec - instead, use
|
99
100
|
*em_before/em_after* hooks that run inside the EM event loop. One more note: you don't need
|
100
|
-
to call
|
101
|
+
to call #done inside *em_before/em_after*, otherwise it'll shut down the reactor.
|
101
102
|
|
102
103
|
|
103
104
|
describe AMQP do
|
@@ -132,7 +133,7 @@ to call 'done' inside *em_before/em_after*, otherwise it'll shut down the reacto
|
|
132
133
|
end
|
133
134
|
|
134
135
|
Finally, you can include AMQP::EMSpec in your describe block. This will run all the group
|
135
|
-
examples inside em block instead of amqp. *before/after* hooks should be finished
|
136
|
+
examples inside em block instead of amqp. Non-evented *before/after* hooks should be finished
|
136
137
|
with #done, same as when including AMQP::Spec, and same caution about using them applies.
|
137
138
|
|
138
139
|
describe AMQP do
|
@@ -221,11 +222,12 @@ Something like this will do the trick:
|
|
221
222
|
|
222
223
|
==Limitations
|
223
224
|
|
224
|
-
AMQP-Spec can be currently used with Rspec only. I suppose,
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
225
|
+
AMQP-Spec can be currently used with Rspec only. I suppose, it is not that difficult to
|
226
|
+
extend EM-Spec's Test::Unit and Bacon support, I just do not have experience doing it.
|
227
|
+
|
228
|
+
Another limitation, library uses 1.9 syntax and therefore not compatible with Ruby 1.8.
|
229
|
+
Again, it seems possible to rewrite it in 1.8-compatible style, with string evals and
|
230
|
+
all such, but I'd rather leave this work to someone else.
|
229
231
|
|
230
232
|
Any help improving this library is greatly appreciated...
|
231
233
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fiber' unless Fiber.respond_to?(:current)
|
1
|
+
#require 'fiber' unless Fiber.respond_to?(:current)
|
2
2
|
|
3
3
|
module AMQP
|
4
4
|
|
@@ -99,7 +99,8 @@ module AMQP
|
|
99
99
|
|
100
100
|
end # class EventedExample
|
101
101
|
|
102
|
-
|
102
|
+
|
103
|
+
# Represents spec running inside EM.run loop
|
103
104
|
class EMExample < EventedExample
|
104
105
|
|
105
106
|
# Run @block inside the EM.run event loop
|
@@ -120,7 +121,8 @@ module AMQP
|
|
120
121
|
end # done
|
121
122
|
end # class EMExample < EventedExample
|
122
123
|
|
123
|
-
|
124
|
+
|
125
|
+
# Represents spec running inside AMQP.start loop
|
124
126
|
class AMQPExample < EventedExample
|
125
127
|
|
126
128
|
# Run @block inside the AMQP.start loop
|
@@ -149,7 +151,7 @@ module AMQP
|
|
149
151
|
end
|
150
152
|
|
151
153
|
# Called from run_event_loop when event loop is finished, before any exceptions
|
152
|
-
# is raised or example returns. We ensure AMQP state cleanup here
|
154
|
+
# is raised or example returns. We ensure AMQP state cleanup here.
|
153
155
|
def finish_example
|
154
156
|
AMQP.cleanup_state
|
155
157
|
super
|
data/lib/amqp-spec/rspec.rb
CHANGED
@@ -115,6 +115,9 @@ module AMQP
|
|
115
115
|
# force spec to timeout if something goes wrong and EM/AMQP loop hangs for some
|
116
116
|
# reason. SpecTimeoutExceededError is raised if it happens.
|
117
117
|
#
|
118
|
+
# For compatibility with EM-Spec API, em method accepts either options Hash
|
119
|
+
# or numeric timeout in seconds.
|
120
|
+
#
|
118
121
|
def em opts = {}, &block
|
119
122
|
if opts.is_a? Hash
|
120
123
|
opts[:spec_timeout] ||= self.class.default_timeout
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Arvicco
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-17 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -33,9 +33,24 @@ dependencies:
|
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: bundler
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 0
|
46
|
+
- 0
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: amqp
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
54
|
none: false
|
40
55
|
requirements:
|
41
56
|
- - ~>
|
@@ -46,7 +61,7 @@ dependencies:
|
|
46
61
|
- 7
|
47
62
|
version: 0.6.7
|
48
63
|
type: :runtime
|
49
|
-
version_requirements: *
|
64
|
+
version_requirements: *id003
|
50
65
|
description: Simple API for writing asynchronous EventMachine/AMQP specs. Supports RSpec and RSpec2.
|
51
66
|
email: arvitallian@gmail.com
|
52
67
|
executables: []
|