Sha256: 70379143c966cb7421a1421c15f5ba2f3a7826aac14dd28d4825f05b4f35b28d
Contents?: true
Size: 1.03 KB
Versions: 17
Compression:
Stored size: 1.03 KB
Contents
module RestAssured class Response def self.perform(app) request = app.request if d = Models::Double.where(:fullpath => request.fullpath, :active => true, :verb => request.request_method).first return_double app, d elsif redirect_url = Models::Redirect.find_redirect_url_for(request.fullpath) if d = Models::Double.where(:fullpath => redirect_url, :active => true, :verb => request.request_method).first return_double app, d else app.redirect redirect_url end else app.status 404 end end def self.return_double(app, d) request = app.request request.body.rewind body = request.body.read #without temp variable ':body = > body' is always nil. mistery env = request.env.except('rack.input', 'rack.errors', 'rack.logger') d.requests.create!(:rack_env => env.to_json, :body => body, :params => request.params.to_json) app.headers d.response_headers app.body d.content app.status d.status end end end
Version data entries
17 entries across 17 versions & 1 rubygems