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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rack/test/poc.rb +39 -28
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed34174c0a0ecacc8a0ab3afcd1d142a9bd32291
4
- data.tar.gz: 0d36e3b67ca0ce77ffba9f74dccf7847d6af234c
3
+ metadata.gz: 7d05c6abc1902b03b4ca81fd6e8f823a51857540
4
+ data.tar.gz: bd58519854c03386706e8f6c7911c2013b25f106
5
5
  SHA512:
6
- metadata.gz: 9f89b386c4827ff526a5b36ab592aeaa57819c33cd86dc3f1fbe1ec4e163155147e366e8fc82f43ffad750e1195de40aaa4db2fb1946b9b99357431702077336
7
- data.tar.gz: 68f6d61dd6dd02b4869c6b3c837bf86c9f852be959843efa908adc91d4b3813801db5c801d1b9c387d862bd7f5cfcdeb05e09f0aa956afa36d4e1507d26c95ee
6
+ metadata.gz: 1a8305bd36d153dc6cf5f143737c0a9c705de9a202f0a2630ddc46215119aa2408d3a010cd5f27371b02958e74201e6e5bee1de202d7860ab69932a7498ddb7d
7
+ data.tar.gz: ebfd8e5efea6e4152dbd9c3780f61e5e05691bc918a75e3b3780f6235668cd526ceaedceecf68d3df09b760839624b17439d798560480db7df24e286a6800309
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
1
+ 3.0.0
@@ -7,9 +7,11 @@ module RackTestPoc
7
7
  def is_for(description_text)
8
8
  return unless RackTestPoc.last_poc
9
9
 
10
- old_body = RackTestPoc.last_poc['response']['body']['object']
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 __init_dump_poc__
96
- $rack_test_poc_dump_export ||= -> {
97
- Kernel.at_exit do
97
+ def __write_out__
98
98
 
99
- require 'yaml'
100
- require 'fileutils'
99
+ require 'yaml'
100
+ require 'fileutils'
101
101
 
102
- dump_dir = File.join RackTestPoc.root,'test','poc'
103
- FileUtils.mkdir_p(dump_dir) unless File.exist?(dump_dir)
102
+ dump_dir = File.join RackTestPoc.root,'test','poc'
103
+ FileUtils.mkdir_p(dump_dir) unless File.exist?(dump_dir)
104
104
 
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
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
- end
109
+ end
110
+
111
+ end
110
112
 
111
- end;true
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
- RackTestPoc.dump_object[uri][request_method_str]['response'] ||= {}
157
- RackTestPoc.dump_object[uri][request_method_str]['request'] ||= {}
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
- RackTestPoc.dump_object[uri][request_method_str]['request']['query'] ||= {}
175
- RackTestPoc.dump_object[uri][request_method_str]['request']['query']['raw'] = raw_query
176
- RackTestPoc.dump_object[uri][request_method_str]['request']['query']['object'] = query_hash
177
- RackTestPoc.dump_object[uri][request_method_str]['request']['headers'] = @headers
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
- RackTestPoc.dump_object[uri][request_method_str]['response']['body']= {}
189
+ last_response_poc['response']['body'] = {}
180
190
 
181
- RackTestPoc.dump_object[uri][request_method_str]['response']['body']['object'] = body
182
- RackTestPoc.dump_object[uri][request_method_str]['response']['body']['raw'] = last_response.body
191
+ last_response_poc['response']['body']['object'] = body
192
+ last_response_poc['response']['body']['raw'] = last_response.body
183
193
 
184
- # RackTestPoc.dump_object[uri][request_method_str]['response']['headers']= env.reduce({}){
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
- RackTestPoc.dump_object[uri][request_method_str]['response']['status']= last_response.status
189
- RackTestPoc.dump_object[uri][request_method_str]['response']['format']= format
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
- # RackTestPoc.dump_object[uri][request_method_str]['response']['content_type']= env['CONTENT_TYPE']
202
+ # last_response_poc['response']['content_type']= env['CONTENT_TYPE']
193
203
  # end
194
204
 
195
- RackTestPoc.last_poc = RackTestPoc.dump_object[uri][request_method_str]
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-test-poc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi