async_rack_test 0.0.2 → 0.0.3
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/CHANGELOG.rdoc +8 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +1 -0
- data/lib/async_rack_test/resync_app.rb +2 -2
- data/lib/async_rack_test/version.rb +1 -1
- data/spec/async_rack_test_spec.rb +22 -0
- metadata +24 -29
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -16,8 +16,8 @@ module AsyncRackTest
|
|
|
16
16
|
result = nil
|
|
17
17
|
env['async.callback'] = method(:write_async_response)
|
|
18
18
|
EM.run do
|
|
19
|
-
response = app.call(env)
|
|
20
|
-
if response[0] == -1
|
|
19
|
+
response = catch(:async) { app.call(env) }
|
|
20
|
+
if response.nil? || response[0] == -1
|
|
21
21
|
EM.add_periodic_timer(0.1) do
|
|
22
22
|
unless @async_response.nil?
|
|
23
23
|
result = @async_response
|
|
@@ -101,6 +101,28 @@ describe AsyncRackTest do
|
|
|
101
101
|
@result.should == [200, {}, []]
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
it "should return when the passed in app throws :async", :slow => true do
|
|
105
|
+
@trigger_async = nil
|
|
106
|
+
async_app = Proc.new do |env|
|
|
107
|
+
EM.add_periodic_timer(0.01) do
|
|
108
|
+
if @trigger_async # This lets us control when the async behavior actually happens.
|
|
109
|
+
env['async.callback'].call [200, {}, []]
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
throw :async
|
|
113
|
+
end
|
|
114
|
+
resync_app = AsyncRackTest::ResyncApp.new(async_app)
|
|
115
|
+
|
|
116
|
+
@result = nil
|
|
117
|
+
thread = Thread.new { @result = resync_app.call({}) }
|
|
118
|
+
|
|
119
|
+
sleep 1 # Give some time to guarantee the thread has had time to run.
|
|
120
|
+
@result.should be_nil
|
|
121
|
+
@trigger_async = true
|
|
122
|
+
thread.join
|
|
123
|
+
@result.should == [200, {}, []]
|
|
124
|
+
end
|
|
125
|
+
|
|
104
126
|
it "should return instantly when the passed in app is not async", :slow => true do
|
|
105
127
|
@trigger_async = nil
|
|
106
128
|
async_app = Proc.new do |env|
|
metadata
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: async_rack_test
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.3
|
|
4
5
|
prerelease:
|
|
5
|
-
version: 0.0.2
|
|
6
6
|
platform: ruby
|
|
7
|
-
authors:
|
|
7
|
+
authors:
|
|
8
8
|
- Paul Cortens
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
|
|
13
|
-
date: 2012-06-12 00:00:00 Z
|
|
12
|
+
date: 2013-09-30 00:00:00.000000000 Z
|
|
14
13
|
dependencies: []
|
|
15
|
-
|
|
16
14
|
description: Extends rack-test to make working with EventMachine easier.
|
|
17
15
|
email: paul@thoughtless.ca
|
|
18
16
|
executables: []
|
|
19
|
-
|
|
20
17
|
extensions: []
|
|
21
|
-
|
|
22
|
-
extra_rdoc_files:
|
|
18
|
+
extra_rdoc_files:
|
|
23
19
|
- README.rdoc
|
|
24
20
|
- CHANGELOG.rdoc
|
|
25
|
-
files:
|
|
21
|
+
files:
|
|
26
22
|
- .gitignore
|
|
27
23
|
- .rspec
|
|
28
24
|
- CHANGELOG.rdoc
|
|
@@ -37,30 +33,29 @@ files:
|
|
|
37
33
|
- spec/spec_helper.rb
|
|
38
34
|
homepage: http://github.com/thoughtless/async_rack_test
|
|
39
35
|
licenses: []
|
|
40
|
-
|
|
41
36
|
post_install_message:
|
|
42
|
-
rdoc_options:
|
|
37
|
+
rdoc_options:
|
|
43
38
|
- --charset=UTF-8
|
|
44
|
-
require_paths:
|
|
39
|
+
require_paths:
|
|
45
40
|
- lib
|
|
46
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
42
|
none: false
|
|
48
|
-
requirements:
|
|
49
|
-
- -
|
|
50
|
-
- !ruby/object:Gem::Version
|
|
51
|
-
version:
|
|
52
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ! '>='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
48
|
none: false
|
|
54
|
-
requirements:
|
|
55
|
-
- -
|
|
56
|
-
- !ruby/object:Gem::Version
|
|
57
|
-
version:
|
|
49
|
+
requirements:
|
|
50
|
+
- - ! '>='
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
58
53
|
requirements: []
|
|
59
|
-
|
|
60
54
|
rubyforge_project:
|
|
61
|
-
rubygems_version: 1.8.
|
|
55
|
+
rubygems_version: 1.8.23
|
|
62
56
|
signing_key:
|
|
63
57
|
specification_version: 3
|
|
64
|
-
summary: async_rack_test-0.0.
|
|
65
|
-
test_files:
|
|
66
|
-
|
|
58
|
+
summary: async_rack_test-0.0.3
|
|
59
|
+
test_files:
|
|
60
|
+
- spec/async_rack_test_spec.rb
|
|
61
|
+
- spec/spec_helper.rb
|