async_rack_test 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.0.3 / 2013-09-30
2
+
3
+ * Add support for libs that `throw :async`. Thanks to https://github.com/paviensky
4
+
5
+ === 0.0.2 / 2012-02-27
6
+
7
+ * Add configurable timeout
8
+
1
9
  === 0.0.1 / 2012-02-23
2
10
 
3
11
  * Initial commit, copied from:
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
1
3
  group :test do
2
4
  gem 'rack-test'
3
5
  gem 'rspec'
data/Gemfile.lock CHANGED
@@ -1,4 +1,5 @@
1
1
  GEM
2
+ remote: https://rubygems.org/
2
3
  specs:
3
4
  bacon (1.1.0)
4
5
  diff-lcs (1.1.3)
@@ -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
@@ -1,5 +1,5 @@
1
1
  module AsyncRackTest # :nodoc:
2
2
  module Version
3
- STRING = '0.0.2'
3
+ STRING = '0.0.3'
4
4
  end
5
5
  end
@@ -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: "0"
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: "0"
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
58
53
  requirements: []
59
-
60
54
  rubyforge_project:
61
- rubygems_version: 1.8.11
55
+ rubygems_version: 1.8.23
62
56
  signing_key:
63
57
  specification_version: 3
64
- summary: async_rack_test-0.0.2
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