amqp-spec 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -0
- data/VERSION +1 -1
- data/spec/rspec_amqp_spec.rb +18 -2
- data/spec/shared_examples.rb +9 -9
- metadata +3 -3
data/HISTORY
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/spec/rspec_amqp_spec.rb
CHANGED
@@ -6,7 +6,7 @@ def publish_and_consume_once(queue_name="test_sink", data="data")
|
|
6
6
|
q.subscribe do |hdr, msg|
|
7
7
|
hdr.should be_an MQ::Header
|
8
8
|
msg.should == data
|
9
|
-
done {q.unsubscribe; q.delete}
|
9
|
+
done { q.unsubscribe; q.delete }
|
10
10
|
end
|
11
11
|
EM.add_timer(0.2) do
|
12
12
|
MQ.queue(queue_name).publish data
|
@@ -25,7 +25,7 @@ describe 'Evented AMQP specs' do
|
|
25
25
|
include AMQP::SpecHelper
|
26
26
|
|
27
27
|
default_options AMQP_OPTS if defined? AMQP_OPTS
|
28
|
-
default_timeout 1
|
28
|
+
default_timeout 1
|
29
29
|
|
30
30
|
puts "Default timeout: #{default_timeout}, Default options:"
|
31
31
|
p default_options
|
@@ -40,9 +40,21 @@ describe 'Evented AMQP specs' do
|
|
40
40
|
|
41
41
|
describe AMQP, " when testing with AMQP::Spec" do
|
42
42
|
include AMQP::Spec
|
43
|
+
|
44
|
+
default_options AMQP_OPTS if defined? AMQP_OPTS
|
45
|
+
default_timeout 1
|
46
|
+
|
43
47
|
it_should_behave_like 'Spec examples'
|
44
48
|
|
45
49
|
context 'inside embedded context / example group' do
|
50
|
+
it 'should inherit default_options/metadata from enclosing example group' do
|
51
|
+
# This is a guard against regression on dev box without notice
|
52
|
+
AMQP.conn.instance_variable_get(:@settings)[:host].should == AMQP_OPTS[:host]
|
53
|
+
self.class.default_options[:host].should == AMQP_OPTS[:host]
|
54
|
+
self.class.default_timeout.should == 1
|
55
|
+
done
|
56
|
+
end
|
57
|
+
|
46
58
|
it_should_behave_like 'Spec examples'
|
47
59
|
end
|
48
60
|
end
|
@@ -50,6 +62,8 @@ describe 'Evented AMQP specs' do
|
|
50
62
|
describe AMQP, " tested with AMQP::SpecHelper when Rspec failures occur" do
|
51
63
|
include AMQP::SpecHelper
|
52
64
|
|
65
|
+
default_options AMQP_OPTS if defined? AMQP_OPTS
|
66
|
+
|
53
67
|
it "bubbles failing expectations up to Rspec" do
|
54
68
|
expect {
|
55
69
|
amqp do
|
@@ -77,6 +91,8 @@ describe 'Evented AMQP specs' do
|
|
77
91
|
describe 'MQ', " when MQ.queue/fanout/topic tries to access Thread.current[:mq] across examples" do
|
78
92
|
include AMQP::SpecHelper
|
79
93
|
|
94
|
+
default_options AMQP_OPTS if defined? AMQP_OPTS
|
95
|
+
|
80
96
|
it 'sends data to the queue' do
|
81
97
|
publish_and_consume_once
|
82
98
|
end
|
data/spec/shared_examples.rb
CHANGED
@@ -83,7 +83,7 @@ shared_examples_for 'done examples' do
|
|
83
83
|
done(0.2) { @block_called = true; EM.reactor_running?.should == true }
|
84
84
|
end
|
85
85
|
@block_called.should == true
|
86
|
-
(Time.now-start).should be_close(0.2, 0.
|
86
|
+
(Time.now-start).should be_close(0.2, 0.1)
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should have delayed done (when em is used)' do
|
@@ -92,7 +92,7 @@ shared_examples_for 'done examples' do
|
|
92
92
|
done(0.2) { @block_called = true; EM.reactor_running?.should == true }
|
93
93
|
end
|
94
94
|
@block_called.should == true
|
95
|
-
(Time.now-start).should be_close(0.2, 0.
|
95
|
+
(Time.now-start).should be_close(0.2, 0.1)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -133,11 +133,11 @@ shared_examples_for 'timeout examples' do
|
|
133
133
|
|
134
134
|
if rspec2?
|
135
135
|
context 'embedded context can set up separate defaults' do
|
136
|
-
default_timeout 0.
|
136
|
+
default_timeout 0.2 # Can be used to set default :spec_timeout for all your amqp-based specs
|
137
137
|
|
138
|
-
specify 'default timeout should be 0.
|
138
|
+
specify 'default timeout should be 0.2' do
|
139
139
|
expect { amqp { EM.add_timer(2) { done } } }.to raise_error SpecTimeoutExceededError
|
140
|
-
(Time.now-@start).should be_close(0.
|
140
|
+
(Time.now-@start).should be_close(0.2, 0.1)
|
141
141
|
end
|
142
142
|
|
143
143
|
context 'deeply embedded context can set up separate defaults' do
|
@@ -167,8 +167,8 @@ shared_examples_for 'Spec examples' do
|
|
167
167
|
it 'should have timers' do
|
168
168
|
start = Time.now
|
169
169
|
|
170
|
-
EM.add_timer(0.
|
171
|
-
(Time.now-start).should be_close(0.
|
170
|
+
EM.add_timer(0.2) {
|
171
|
+
(Time.now-start).should be_close(0.2, 0.1)
|
172
172
|
done
|
173
173
|
}
|
174
174
|
end
|
@@ -177,7 +177,7 @@ shared_examples_for 'Spec examples' do
|
|
177
177
|
num = 0
|
178
178
|
start = Time.now
|
179
179
|
|
180
|
-
timer = EM.add_periodic_timer(0.
|
180
|
+
timer = EM.add_periodic_timer(0.2) {
|
181
181
|
if (num += 1) == 2
|
182
182
|
(Time.now-start).should be_close(0.5, 0.1)
|
183
183
|
EM.cancel_timer timer
|
@@ -188,7 +188,7 @@ shared_examples_for 'Spec examples' do
|
|
188
188
|
|
189
189
|
it 'should have deferrables' do
|
190
190
|
defr = EM::DefaultDeferrable.new
|
191
|
-
defr.timeout(0.
|
191
|
+
defr.timeout(0.2)
|
192
192
|
defr.errback {
|
193
193
|
done
|
194
194
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amqp-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arvicco
|