evented-spec 0.9.0 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/HISTORY +5 -0
- data/README.textile +1 -1
- data/VERSION +1 -1
- data/lib/evented-spec/amqp_spec.rb +3 -1
- data/lib/evented-spec/coolio_spec.rb +3 -1
- data/lib/evented-spec/em_spec.rb +3 -1
- data/spec/minitest/amqp_integration_minispec.rb +75 -0
- data/spec/minitest/basic_integration_minispec.rb +45 -0
- data/spec/minitest/coolio_integration_minispec.rb +64 -0
- data/spec/minitest/em_integration_minispec.rb +54 -0
- data/spec/minitest/spec_helper.rb +1 -0
- data/spec/run.rb +18 -0
- data/tasks/spec.rake +2 -1
- metadata +27 -13
data/.gitignore
CHANGED
data/HISTORY
CHANGED
@@ -102,3 +102,8 @@
|
|
102
102
|
* EventedSpec::CoolioSpec module similar to EMSpec and AMQPSpec
|
103
103
|
* coolio_before / coolio_after hooks
|
104
104
|
* #delayed helper
|
105
|
+
|
106
|
+
== 0.4.1 ... 0.10.0.pre / 2011-04-29 ... 2012-02-17
|
107
|
+
|
108
|
+
* API wasn't changed at all
|
109
|
+
* Minitest support (as in 'minitest/spec')
|
data/README.textile
CHANGED
@@ -189,7 +189,7 @@ Reason is simple: if we don't restart event loop every spec example, all kinds o
|
|
189
189
|
|
190
190
|
h2. Compatibility
|
191
191
|
|
192
|
-
EventedSpec is tested with RSpec >= 2.5.0, Cool.io ~> 1.0.0, EventMachine >= 0.12.10, and AMQP >= 0.8.0. Running it with RSpec 1.3 and/or AMQP 0.7.0 is not unheard of, although not tested in all its entirety.
|
192
|
+
EventedSpec is tested with RSpec >= 2.5.0 / Minitest >= 2.11.2, Cool.io ~> 1.0.0, EventMachine >= 0.12.10, and AMQP >= 0.8.0. Running it with RSpec 1.3 and/or AMQP 0.7.0 is not unheard of, although not tested in all its entirety.
|
193
193
|
|
194
194
|
h2. See also
|
195
195
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0.beta1
|
@@ -15,7 +15,9 @@ module EventedSpec
|
|
15
15
|
module ClassMethods
|
16
16
|
def it(*args, &block)
|
17
17
|
if block
|
18
|
-
new_block =
|
18
|
+
new_block = lambda do |*args|
|
19
|
+
amqp(&block)
|
20
|
+
end
|
19
21
|
super(*args, &new_block)
|
20
22
|
else
|
21
23
|
# pending example
|
@@ -14,7 +14,9 @@ module EventedSpec
|
|
14
14
|
if block
|
15
15
|
# Shared example groups seem to pass example group instance
|
16
16
|
# to the actual example block
|
17
|
-
new_block =
|
17
|
+
new_block = lambda do |*args|
|
18
|
+
coolio(&block)
|
19
|
+
end
|
18
20
|
super(*args, &new_block)
|
19
21
|
else
|
20
22
|
# pending example
|
data/lib/evented-spec/em_spec.rb
CHANGED
@@ -14,7 +14,9 @@ module EventedSpec
|
|
14
14
|
if block
|
15
15
|
# Shared example groups seem to pass example group instance
|
16
16
|
# to the actual example block
|
17
|
-
new_block =
|
17
|
+
new_block = lambda do |*args|
|
18
|
+
em(&block)
|
19
|
+
end
|
18
20
|
super(*args, &new_block)
|
19
21
|
else
|
20
22
|
# pending example
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "EventedSpec AMQP bindings" do
|
4
|
+
include EventedSpec::SpecHelper
|
5
|
+
default_timeout 0.5
|
6
|
+
|
7
|
+
def amqp_running?
|
8
|
+
EM.reactor_running? && !!AMQP.connection
|
9
|
+
end # amqp_running?
|
10
|
+
|
11
|
+
|
12
|
+
it "runs after amqp is connected" do
|
13
|
+
amqp_running?.must_equal false
|
14
|
+
amqp do
|
15
|
+
amqp_running?.must_equal true
|
16
|
+
done
|
17
|
+
end
|
18
|
+
amqp_running?.must_equal false
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "hooks" do
|
22
|
+
def hooks
|
23
|
+
@hooks ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
before { hooks << :before }
|
27
|
+
em_before { hooks << :em_before }
|
28
|
+
amqp_before { hooks << :amqp_before }
|
29
|
+
amqp_after { hooks << :amqp_after }
|
30
|
+
em_after { hooks << :em_after }
|
31
|
+
after { hooks << :after }
|
32
|
+
|
33
|
+
it "execute in proper order" do
|
34
|
+
hooks.must_equal [:before]
|
35
|
+
amqp do
|
36
|
+
hooks.must_equal [:before, :em_before, :amqp_before]
|
37
|
+
done
|
38
|
+
end
|
39
|
+
hooks.must_equal [:before, :em_before, :amqp_before,
|
40
|
+
:amqp_after, :em_after]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe EventedSpec::AMQPSpec do
|
45
|
+
include EventedSpec::AMQPSpec
|
46
|
+
|
47
|
+
it "runs after amqp is connected" do
|
48
|
+
amqp_running?.must_equal true
|
49
|
+
done
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "actual amqp functionality" do
|
54
|
+
def publish_and_consume_once(queue_name="test_sink", data="data")
|
55
|
+
AMQP::Channel.new do |channel, _|
|
56
|
+
exchange = channel.direct(queue_name)
|
57
|
+
queue = channel.queue(queue_name).bind(exchange)
|
58
|
+
queue.subscribe do |hdr, msg|
|
59
|
+
hdr.must_be_kind_of AMQP::Header
|
60
|
+
msg.must_equal data
|
61
|
+
done { queue.unsubscribe; queue.delete }
|
62
|
+
end
|
63
|
+
EM.add_timer(0.2) do
|
64
|
+
exchange.publish data
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can connect and publish something" do
|
70
|
+
amqp do
|
71
|
+
publish_and_consume_once
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EventedSpec do
|
4
|
+
describe "inclusion of helper modules" do
|
5
|
+
include EventedSpec::SpecHelper
|
6
|
+
|
7
|
+
it "creates reactor launchers" do
|
8
|
+
[:em, :amqp, :coolio].each do |method|
|
9
|
+
self.respond_to?(method).must_equal true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "adds various helpers" do
|
14
|
+
[:done, :timeout, :delayed].each do |method|
|
15
|
+
self.must_respond_to method
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "creates hooks and other group helpers" do
|
20
|
+
[:em_before, :em_after, :amqp_before,
|
21
|
+
:amqp_after, :coolio_before, :coolio_after,
|
22
|
+
:default_timeout, :default_options].each do |method|
|
23
|
+
self.class.must_respond_to method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "propagation to sub contexts" do
|
28
|
+
it "should work" do
|
29
|
+
[:em, :amqp, :coolio].each do |method|
|
30
|
+
self.must_respond_to method
|
31
|
+
end
|
32
|
+
|
33
|
+
[:done, :timeout, :delayed].each do |method|
|
34
|
+
self.must_respond_to method
|
35
|
+
end
|
36
|
+
|
37
|
+
[:em_before, :em_after, :amqp_before,
|
38
|
+
:amqp_after, :coolio_before, :coolio_after,
|
39
|
+
:default_timeout, :default_options].each do |method|
|
40
|
+
self.class.must_respond_to method
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
if !(RUBY_PLATFORM =~ /java/)
|
4
|
+
describe "EventedSpec cool.io bindings" do
|
5
|
+
def coolio_running?
|
6
|
+
!!Coolio::Loop.default.instance_variable_get(:@running)
|
7
|
+
end # coolio_running?
|
8
|
+
|
9
|
+
include EventedSpec::SpecHelper
|
10
|
+
default_timeout 0.5
|
11
|
+
|
12
|
+
it "can run inside of em loop" do
|
13
|
+
coolio_running?.must_equal false
|
14
|
+
coolio do
|
15
|
+
coolio_running?.must_equal true
|
16
|
+
done
|
17
|
+
end
|
18
|
+
coolio_running?.must_equal false
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "hooks" do
|
22
|
+
describe "hooks" do
|
23
|
+
def hooks
|
24
|
+
@hooks ||= []
|
25
|
+
end
|
26
|
+
|
27
|
+
before { hooks << :before }
|
28
|
+
coolio_before { hooks << :coolio_before }
|
29
|
+
coolio_after { hooks << :coolio_after }
|
30
|
+
after { hooks << :after }
|
31
|
+
|
32
|
+
it "execute in proper order" do
|
33
|
+
hooks.must_equal [:before]
|
34
|
+
coolio do
|
35
|
+
hooks.must_equal [:before, :coolio_before]
|
36
|
+
done
|
37
|
+
end
|
38
|
+
hooks.must_equal [:before, :coolio_before, :coolio_after]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
describe "#delayed" do
|
45
|
+
default_timeout 0.7
|
46
|
+
it "works as intended" do
|
47
|
+
coolio do
|
48
|
+
time = Time.now
|
49
|
+
delayed(0.3) { Time.now.must_be_close_to time + 0.3, 0.1 }
|
50
|
+
done(0.4)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe EventedSpec::CoolioSpec do
|
56
|
+
include EventedSpec::CoolioSpec
|
57
|
+
it "wraps the whole example" do
|
58
|
+
coolio_running?.must_equal true
|
59
|
+
done
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "EventedSpec EventMachine bindings" do
|
4
|
+
include EventedSpec::SpecHelper
|
5
|
+
default_timeout 0.5
|
6
|
+
|
7
|
+
it "can run inside of em loop" do
|
8
|
+
EM.reactor_running?.must_equal false
|
9
|
+
em do
|
10
|
+
EM.reactor_running?.must_equal true
|
11
|
+
done
|
12
|
+
end
|
13
|
+
EM.reactor_running?.must_equal false
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "hooks" do
|
17
|
+
def hooks
|
18
|
+
@hooks ||= []
|
19
|
+
end
|
20
|
+
|
21
|
+
before { hooks << :before }
|
22
|
+
em_before { hooks << :em_before }
|
23
|
+
em_after { hooks << :em_after }
|
24
|
+
after { hooks << :after }
|
25
|
+
|
26
|
+
it "execute in proper order" do
|
27
|
+
hooks.must_equal [:before]
|
28
|
+
em do
|
29
|
+
hooks.must_equal [:before, :em_before]
|
30
|
+
done
|
31
|
+
end
|
32
|
+
hooks.must_equal [:before, :em_before, :em_after]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#delayed" do
|
37
|
+
default_timeout 0.7
|
38
|
+
it "works as intended" do
|
39
|
+
em do
|
40
|
+
time = Time.now
|
41
|
+
delayed(0.3) { Time.now.must_be_close_to time + 0.3, 0.1 }
|
42
|
+
done(0.4)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe EventedSpec::EMSpec do
|
48
|
+
include EventedSpec::EMSpec
|
49
|
+
it "wraps the whole example" do
|
50
|
+
EM.reactor_running?.must_equal true
|
51
|
+
done
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'evented-spec'
|
data/spec/run.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
Bundler.require :default, :test
|
4
|
+
|
5
|
+
spec_dir = File.expand_path("..", __FILE__)
|
6
|
+
lib_dir = File.expand_path("../../lib", __FILE__)
|
7
|
+
if ARGV.delete('--minitest')
|
8
|
+
require 'minitest/spec'
|
9
|
+
require 'minitest/autorun'
|
10
|
+
$LOAD_PATH.unshift "#{spec_dir}/minitest"
|
11
|
+
$LOAD_PATH.unshift lib_dir
|
12
|
+
Dir.glob("#{spec_dir}/**/*_minispec.rb").each {|spec| require spec }
|
13
|
+
else
|
14
|
+
require 'rspec'
|
15
|
+
require 'rspec/autorun'
|
16
|
+
Dir.glob("#{spec_dir}/**/*_spec.rb").each {|spec| require spec }
|
17
|
+
end
|
18
|
+
|
data/tasks/spec.rake
CHANGED
@@ -8,8 +8,9 @@ namespace :spec do
|
|
8
8
|
RSpec::Core::RakeTask.new(:all){|task|}
|
9
9
|
|
10
10
|
desc "Run all non-failing specs (for CI)"
|
11
|
-
|
11
|
+
task(:ci) do |task|
|
12
12
|
ENV["EXCLUDE_DELIBERATELY_FAILING_SPECS"] = "1"
|
13
|
+
exec "ruby spec/run.rb && ruby spec/run.rb --minitest"
|
13
14
|
end
|
14
15
|
|
15
16
|
desc "Run specs with RCov"
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evented-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3099509867
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
- 9
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- beta
|
11
|
+
- 1
|
12
|
+
version: 1.0.0.beta1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Arvicco
|
@@ -16,8 +18,7 @@ autorequire:
|
|
16
18
|
bindir: bin
|
17
19
|
cert_chain: []
|
18
20
|
|
19
|
-
date:
|
20
|
-
default_executable:
|
21
|
+
date: 2012-02-18 00:00:00 Z
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: rspec
|
@@ -43,7 +44,7 @@ dependencies:
|
|
43
44
|
requirements:
|
44
45
|
- - ~>
|
45
46
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
47
|
+
hash: 1956222863
|
47
48
|
segments:
|
48
49
|
- 0
|
49
50
|
- 8
|
@@ -137,6 +138,12 @@ files:
|
|
137
138
|
- spec/evented-spec/evented_spec_metadata_spec.rb
|
138
139
|
- spec/evented-spec/util_spec.rb
|
139
140
|
- spec/integration/failing_rspec_spec.rb
|
141
|
+
- spec/minitest/amqp_integration_minispec.rb
|
142
|
+
- spec/minitest/basic_integration_minispec.rb
|
143
|
+
- spec/minitest/coolio_integration_minispec.rb
|
144
|
+
- spec/minitest/em_integration_minispec.rb
|
145
|
+
- spec/minitest/spec_helper.rb
|
146
|
+
- spec/run.rb
|
140
147
|
- spec/spec.opts
|
141
148
|
- spec/spec_helper.rb
|
142
149
|
- tasks/common.rake
|
@@ -151,7 +158,6 @@ files:
|
|
151
158
|
- VERSION
|
152
159
|
- HISTORY
|
153
160
|
- .gitignore
|
154
|
-
has_rdoc: true
|
155
161
|
homepage: http://github.com/ruby-amqp/evented-spec
|
156
162
|
licenses: []
|
157
163
|
|
@@ -177,16 +183,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
184
|
none: false
|
179
185
|
requirements:
|
180
|
-
- - "
|
186
|
+
- - ">"
|
181
187
|
- !ruby/object:Gem::Version
|
182
|
-
hash:
|
188
|
+
hash: 25
|
183
189
|
segments:
|
184
|
-
-
|
185
|
-
|
190
|
+
- 1
|
191
|
+
- 3
|
192
|
+
- 1
|
193
|
+
version: 1.3.1
|
186
194
|
requirements: []
|
187
195
|
|
188
196
|
rubyforge_project: evented-spec
|
189
|
-
rubygems_version: 1.
|
197
|
+
rubygems_version: 1.8.15
|
190
198
|
signing_key:
|
191
199
|
specification_version: 3
|
192
200
|
summary: Simple API for writing asynchronous EventMachine/AMQP specs. Supports RSpec and RSpec2.
|
@@ -201,5 +209,11 @@ test_files:
|
|
201
209
|
- spec/evented-spec/evented_spec_metadata_spec.rb
|
202
210
|
- spec/evented-spec/util_spec.rb
|
203
211
|
- spec/integration/failing_rspec_spec.rb
|
212
|
+
- spec/minitest/amqp_integration_minispec.rb
|
213
|
+
- spec/minitest/basic_integration_minispec.rb
|
214
|
+
- spec/minitest/coolio_integration_minispec.rb
|
215
|
+
- spec/minitest/em_integration_minispec.rb
|
216
|
+
- spec/minitest/spec_helper.rb
|
217
|
+
- spec/run.rb
|
204
218
|
- spec/spec.opts
|
205
219
|
- spec/spec_helper.rb
|