request-replay 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74c29ee7f631fdfaaddd0bcde2083d204a7123b9
4
- data.tar.gz: 9ea9ce6b5e376a5fb7ea32a898b996aed9696b73
3
+ metadata.gz: 757f765cde5cb73d14e26de907f2bc03322973ee
4
+ data.tar.gz: 0fa338334b76b3d678a2e676a3fe86e19a1d5cff
5
5
  SHA512:
6
- metadata.gz: 29ee655a7da33ac820fa14fe8e7af2f517135ff500790437b7cbfb2d2f4f71c188943e73ad834cfdcb723467bd91d56294d075df454b7c8744487c257202dc9b
7
- data.tar.gz: 2de2ed416688b4b8d2cbc3a368cabf1b7b7f9587ee736b1ae0b2725bbcd4af4a0dc46059b1b595d7978ea97bcc0222631f7926072ce6e50fdf02a26c5bd6bba9
6
+ metadata.gz: 3c9a20be6d4bb76253ddebefd6aa54176564d7909b8508e1e7bd02fada6d0e9a7c986f6a678bde351276af31a34c0f4d4a1ab63ada383990369a33062789d19f
7
+ data.tar.gz: 739d4d94923788d1e27f1f12539c03c7182e1679ed601164e39d655bb2ab147a8061aef27c85ca0fbad557a3ed9af8a54df6d7a0bfe88dc84c93f2fe8a4dabd0
data/CHANGES.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGES
2
2
 
3
+ ## request-replay 0.6.1 -- 2013-10-01
4
+
5
+ * Print error messages to env['rack.errors']
6
+ * Fixed a bug where the underlying Rack app might be modifying
7
+ the original env, making request-replay cannot reliably rebuild
8
+ the request.
9
+
3
10
  ## request-replay 0.6.0 -- 2013-10-01
4
11
 
5
12
  * Added :read_wait option for waiting for the remote server responding.
data/Rakefile CHANGED
@@ -8,6 +8,6 @@ end
8
8
 
9
9
  Gemgem.init(dir) do |s|
10
10
  s.name = 'request-replay'
11
- s.version = '0.6.0'
11
+ s.version = '0.6.1'
12
12
  %w[bacon muack rack].each{ |g| s.add_development_dependency(g) }
13
13
  end
@@ -34,6 +34,9 @@ class RequestReplay
34
34
  sock.close_write
35
35
  IO.select([sock], [], [], read_wait) if read_wait
36
36
  yield(sock) if block_given?
37
+ rescue => e
38
+ @env['rack.errors'].puts("[#{self.class.name}] Error: #{e.inspect}") if
39
+ @env['rack.errors']
37
40
  ensure
38
41
  sock.close
39
42
  end
@@ -8,8 +8,10 @@ class RequestReplay::Middleware
8
8
 
9
9
  def call env
10
10
  # We don't want to read the socket in a thread, so create it in main
11
- # thread, and send the data in a thread as we don't care the responses
12
- Thread.new(RequestReplay.new(env, @host, @options), &:start)
11
+ # thread, and send the data in a thread as we don't care the responses.
12
+ # Also, unfortunately, we need to dup env because other middleware
13
+ # might be modifying it and make it not able to get the original env.
14
+ Thread.new(RequestReplay.new(env.dup, @host, @options), &:start)
13
15
  @app.call(env)
14
16
  end
15
17
  end
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: request-replay 0.6.0 ruby lib
2
+ # stub: request-replay 0.6.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "request-replay"
6
- s.version = "0.6.0"
6
+ s.version = "0.6.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.authors = ["Lin Jen-Shin (godfat)"]
@@ -40,6 +40,10 @@ describe RequestReplay do
40
40
  end
41
41
  end
42
42
 
43
+ after do
44
+ Muack.verify
45
+ end
46
+
43
47
  should 'GET' do
44
48
  verify[request[{'REQUEST_METHOD' => 'GET'}, 'Host' => 'ex.com'], <<-HTTP]
45
49
  GET /?q=1 HTTP/1.1\r
@@ -77,19 +81,53 @@ Pork: BEEF\r
77
81
  HTTP
78
82
  end
79
83
 
80
- describe RequestReplay::Middleware do
81
- app = Rack::Builder.app do
82
- use RequestReplay::Middleware, hopt
83
- run lambda{ |env| [200, {}, []] }
84
+ should 'puts error' do
85
+ any_instance_of(TCPSocket) do |sock|
86
+ mock(sock).read{ raise 'ERROR' }
87
+ end
88
+
89
+ errors = StringIO.new
90
+ begin
91
+ request['rack.errors' => errors].value
92
+ ensure
93
+ serv.accept.close
84
94
  end
95
+ errors.string.should.start_with? '[RequestReplay] Error:'
96
+ end
85
97
 
98
+ describe RequestReplay::Middleware do
86
99
  should 'PUT' do
100
+ app = Rack::Builder.app do
101
+ use RequestReplay::Middleware, hopt
102
+ run lambda{ |env| [200, {}, []] }
103
+ end
104
+
87
105
  app.call(env.merge('REQUEST_METHOD' => 'PUT'))
88
106
  sock = serv.accept
89
107
  sock.read.should.eq <<-HTTP
90
108
  PUT /?q=1 HTTP/1.1\r
91
109
  Host: localhost\r
92
110
  Pork: BEEF\r
111
+ \r
112
+ HTTP
113
+ sock.close
114
+ end
115
+
116
+ should 'retain original env' do
117
+ app = Rack::Builder.app do
118
+ use RequestReplay::Middleware, hopt
119
+ run lambda{ |env|
120
+ env['PATH_INFO'] = '/bad'
121
+ [200, {}, []]
122
+ }
123
+ end
124
+
125
+ app.call(env)
126
+ sock = serv.accept
127
+ sock.read.should.eq <<-HTTP
128
+ GET /?q=1 HTTP/1.1\r
129
+ Host: localhost\r
130
+ Pork: BEEF\r
93
131
  \r
94
132
  HTTP
95
133
  sock.close
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request-replay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)