m2r 2.0.1 → 2.0.2
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.md +5 -0
- data/lib/m2r/rack_handler.rb +1 -0
- data/lib/m2r/version.rb +1 -1
- data/test/unit/connection_test.rb +4 -4
- data/test/unit/rack_handler_test.rb +24 -0
- metadata +5 -4
data/CHANGELOG.md
ADDED
data/lib/m2r/rack_handler.rb
CHANGED
data/lib/m2r/version.rb
CHANGED
@@ -44,7 +44,7 @@ module M2R
|
|
44
44
|
assert_equal "uuid 11:conn1 conn2, ddaattaa", msg
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
47
|
+
def test_string_reply_non_close
|
48
48
|
connection = Connection.new(@request_socket, @response_socket)
|
49
49
|
connection.reply( stub(sender: 'uuid', conn_id: 'conn1', close?: false), 'ddaattaa')
|
50
50
|
assert_equal 0, @sub.recv_string(msg = "")
|
@@ -52,7 +52,7 @@ module M2R
|
|
52
52
|
assert_equal -1, @sub.recv_string(msg = "", ZMQ::NOBLOCK)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def test_string_reply_close
|
56
56
|
connection = Connection.new(@request_socket, @response_socket)
|
57
57
|
connection.reply( stub(sender: 'uuid', conn_id: 'conn1', close?: true), 'ddaattaa')
|
58
58
|
assert_equal 0, @sub.recv_string(msg = "")
|
@@ -61,7 +61,7 @@ module M2R
|
|
61
61
|
assert_equal "uuid 5:conn1, ", msg
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def test_response_reply_non_close
|
65
65
|
connection = Connection.new(@request_socket, @response_socket)
|
66
66
|
connection.reply( stub(sender: 'uuid', conn_id: 'conn1'), mock(to_s: 'ddaattaa', close?: false))
|
67
67
|
assert_equal 0, @sub.recv_string(msg = "")
|
@@ -69,7 +69,7 @@ module M2R
|
|
69
69
|
assert_equal -1, @sub.recv_string(msg = "", ZMQ::NOBLOCK)
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def test_response_reply_close
|
73
73
|
connection = Connection.new(@request_socket, @response_socket)
|
74
74
|
connection.reply( stub(sender: 'uuid', conn_id: 'conn1'), mock(to_s: 'ddaattaa', close?: true))
|
75
75
|
assert_equal 0, @sub.recv_string(msg = "")
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'm2r/rack_handler'
|
3
3
|
require 'm2r/connection_factory'
|
4
|
+
require 'tempfile'
|
4
5
|
|
5
6
|
class HelloWorld
|
6
7
|
def call(env)
|
@@ -8,6 +9,15 @@ class HelloWorld
|
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
12
|
+
class HelloWorldFile
|
13
|
+
def call(env)
|
14
|
+
Thread.current[:tempfile] = t = Tempfile.new("asd")
|
15
|
+
t << "Hello world!\n"
|
16
|
+
t.rewind
|
17
|
+
return [201, {'Content-Type' => 'text/plain'}, t]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
11
21
|
module M2R
|
12
22
|
class ConnectionFactory
|
13
23
|
class Custom
|
@@ -48,6 +58,16 @@ module M2R
|
|
48
58
|
assert_equal 200, response.status
|
49
59
|
end
|
50
60
|
|
61
|
+
def test_file_closed
|
62
|
+
factory = stub(:connection)
|
63
|
+
handler = RackHandler.new(file_app, factory, Request)
|
64
|
+
response = handler.process(root_request)
|
65
|
+
|
66
|
+
assert_equal "Hello world!\n", response.body
|
67
|
+
assert_equal 201, response.status
|
68
|
+
assert Thread.current[:tempfile].closed?
|
69
|
+
end
|
70
|
+
|
51
71
|
def test_custom_connection_factory
|
52
72
|
require 'rack/handler/mongrel2'
|
53
73
|
handler = ::Rack::Handler::Mongrel2
|
@@ -72,5 +92,9 @@ module M2R
|
|
72
92
|
def app
|
73
93
|
Rack::Lint.new(HelloWorld.new)
|
74
94
|
end
|
95
|
+
|
96
|
+
def file_app
|
97
|
+
Rack::Lint.new(HelloWorldFile.new)
|
98
|
+
end
|
75
99
|
end
|
76
100
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: m2r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-11-
|
15
|
+
date: 2012-11-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: ffi-rzmq
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- .gitignore
|
238
238
|
- .travis.yml
|
239
239
|
- .yardopts
|
240
|
+
- CHANGELOG.md
|
240
241
|
- Gemfile
|
241
242
|
- LICENSE
|
242
243
|
- README.md
|
@@ -295,7 +296,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
295
296
|
version: '0'
|
296
297
|
segments:
|
297
298
|
- 0
|
298
|
-
hash:
|
299
|
+
hash: 2084611234703019484
|
299
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
300
301
|
none: false
|
301
302
|
requirements:
|
@@ -304,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
305
|
version: '0'
|
305
306
|
segments:
|
306
307
|
- 0
|
307
|
-
hash:
|
308
|
+
hash: 2084611234703019484
|
308
309
|
requirements: []
|
309
310
|
rubyforge_project:
|
310
311
|
rubygems_version: 1.8.23
|