rack-test-poc 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/test/poc.rb +39 -28
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d05c6abc1902b03b4ca81fd6e8f823a51857540
|
4
|
+
data.tar.gz: bd58519854c03386706e8f6c7911c2013b25f106
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a8305bd36d153dc6cf5f143737c0a9c705de9a202f0a2630ddc46215119aa2408d3a010cd5f27371b02958e74201e6e5bee1de202d7860ab69932a7498ddb7d
|
7
|
+
data.tar.gz: ebfd8e5efea6e4152dbd9c3780f61e5e05691bc918a75e3b3780f6235668cd526ceaedceecf68d3df09b760839624b17439d798560480db7df24e286a6800309
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/lib/rack/test/poc.rb
CHANGED
@@ -7,9 +7,11 @@ module RackTestPoc
|
|
7
7
|
def is_for(description_text)
|
8
8
|
return unless RackTestPoc.last_poc
|
9
9
|
|
10
|
-
|
10
|
+
# ['description']
|
11
11
|
RackTestPoc.last_poc['response']['body']['description'] ||= ->{
|
12
12
|
|
13
|
+
old_body = RackTestPoc.last_poc['response']['body']['object']
|
14
|
+
|
13
15
|
begin
|
14
16
|
JSON.parse(old_body.to_json) #> hard clone
|
15
17
|
rescue
|
@@ -92,23 +94,29 @@ module RackTestPoc
|
|
92
94
|
|
93
95
|
module EXT
|
94
96
|
|
95
|
-
def
|
96
|
-
$rack_test_poc_dump_export ||= -> {
|
97
|
-
Kernel.at_exit do
|
97
|
+
def __write_out__
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
require 'yaml'
|
100
|
+
require 'fileutils'
|
101
101
|
|
102
|
-
|
103
|
-
|
102
|
+
dump_dir = File.join RackTestPoc.root,'test','poc'
|
103
|
+
FileUtils.mkdir_p(dump_dir) unless File.exist?(dump_dir)
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
unless RackTestPoc.dump_object.empty?
|
106
|
+
File.write File.join(dump_dir,Time.now.to_i.to_s.concat('.yaml')),
|
107
|
+
RackTestPoc.dump_object.to_yaml
|
108
108
|
|
109
|
-
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
110
112
|
|
111
|
-
|
113
|
+
def __init_dump_poc__
|
114
|
+
$rack_test_poc_dump_export ||= -> {
|
115
|
+
if MiniTest::Unit.respond_to?(:after_tests)
|
116
|
+
MiniTest::Unit.after_tests{ __write_out__ }
|
117
|
+
else
|
118
|
+
Kernel.at_exit{ __write_out__ }
|
119
|
+
end
|
112
120
|
}.call
|
113
121
|
end
|
114
122
|
|
@@ -127,7 +135,9 @@ module RackTestPoc
|
|
127
135
|
request_method_str = env['REQUEST_METHOD'].to_s.upcase
|
128
136
|
|
129
137
|
RackTestPoc.dump_object[uri] ||= {}
|
130
|
-
RackTestPoc.dump_object[uri][request_method_str] ||=
|
138
|
+
RackTestPoc.dump_object[uri][request_method_str] ||= []
|
139
|
+
|
140
|
+
last_response_poc = {}
|
131
141
|
|
132
142
|
begin
|
133
143
|
|
@@ -153,8 +163,8 @@ module RackTestPoc
|
|
153
163
|
|
154
164
|
end
|
155
165
|
|
156
|
-
|
157
|
-
|
166
|
+
last_response_poc['response'] ||= {}
|
167
|
+
last_response_poc['request'] ||= {}
|
158
168
|
|
159
169
|
raw_query = env.find{|k,v|
|
160
170
|
%W[ QUERY_STRING rack.request.form_vars ].any?{|tag| k == tag && !v.nil? && v != '' }
|
@@ -171,28 +181,29 @@ module RackTestPoc
|
|
171
181
|
|
172
182
|
end
|
173
183
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
184
|
+
last_response_poc['request']['query'] ||= {}
|
185
|
+
last_response_poc['request']['query']['raw'] = raw_query
|
186
|
+
last_response_poc['request']['query']['object'] = query_hash
|
187
|
+
last_response_poc['request']['headers'] ||= @headers
|
178
188
|
|
179
|
-
|
189
|
+
last_response_poc['response']['body'] = {}
|
180
190
|
|
181
|
-
|
182
|
-
|
191
|
+
last_response_poc['response']['body']['object'] = body
|
192
|
+
last_response_poc['response']['body']['raw'] = last_response.body
|
183
193
|
|
184
|
-
#
|
194
|
+
# last_response_poc['response']['headers']= env.reduce({}){
|
185
195
|
# |m,o| m.merge!(o[0]=>o[1]) if o[0].to_s.downcase =~ /^http_/ ; m
|
186
196
|
# }
|
187
197
|
|
188
|
-
|
189
|
-
|
198
|
+
last_response_poc['response']['status']= last_response.status
|
199
|
+
last_response_poc['response']['format']= format
|
190
200
|
|
191
201
|
# if env['CONTENT_TYPE']
|
192
|
-
#
|
202
|
+
# last_response_poc['response']['content_type']= env['CONTENT_TYPE']
|
193
203
|
# end
|
194
204
|
|
195
|
-
RackTestPoc.
|
205
|
+
RackTestPoc.dump_object[uri][request_method_str] << last_response_poc
|
206
|
+
RackTestPoc.last_poc = last_response_poc
|
196
207
|
|
197
208
|
return last_response
|
198
209
|
|