ok
Direktori : /opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/ |
Current File : //opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/MockRequest.html |
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>class Rack::MockRequest - rack-2.2.8 Documentation</title> <script type="text/javascript"> var rdoc_rel_prefix = "../"; var index_rel_prefix = "../"; </script> <script src="../js/navigation.js" defer></script> <script src="../js/search.js" defer></script> <script src="../js/search_index.js" defer></script> <script src="../js/searcher.js" defer></script> <script src="../js/darkfish.js" defer></script> <link href="../css/fonts.css" rel="stylesheet"> <link href="../css/rdoc.css" rel="stylesheet"> <body id="top" role="document" class="class"> <nav role="navigation"> <div id="project-navigation"> <div id="home-section" role="region" title="Quick navigation" class="nav-section"> <h2> <a href="../index.html" rel="home">Home</a> </h2> <div id="table-of-contents-navigation"> <a href="../table_of_contents.html#pages">Pages</a> <a href="../table_of_contents.html#classes">Classes</a> <a href="../table_of_contents.html#methods">Methods</a> </div> </div> <div id="search-section" role="search" class="project-section initially-hidden"> <form action="#" method="get" accept-charset="utf-8"> <div id="search-field-wrapper"> <input id="search-field" role="combobox" aria-label="Search" aria-autocomplete="list" aria-controls="search-results" type="text" name="search" placeholder="Search" spellcheck="false" title="Type to search, Up and Down to navigate, Enter to load"> </div> <ul id="search-results" aria-label="Search Results" aria-busy="false" aria-expanded="false" aria-atomic="false" class="initially-hidden"></ul> </form> </div> </div> <div id="class-metadata"> <div id="parent-class-section" class="nav-section"> <h3>Parent</h3> <p class="link">Object </div> <!-- Method Quickref --> <div id="method-list-section" class="nav-section"> <h3>Methods</h3> <ul class="link-list" role="directory"> <li ><a href="#method-c-env_for">::env_for</a> <li ><a href="#method-c-new">::new</a> <li ><a href="#method-c-parse_uri_rfc2396">::parse_uri_rfc2396</a> <li ><a href="#method-i-delete">#delete</a> <li ><a href="#method-i-get">#get</a> <li ><a href="#method-i-head">#head</a> <li ><a href="#method-i-options">#options</a> <li ><a href="#method-i-patch">#patch</a> <li ><a href="#method-i-post">#post</a> <li ><a href="#method-i-put">#put</a> <li ><a href="#method-i-request">#request</a> </ul> </div> </div> </nav> <main role="main" aria-labelledby="class-Rack::MockRequest"> <h1 id="class-Rack::MockRequest" class="class"> class Rack::MockRequest </h1> <section class="description"> <p><a href="MockRequest.html"><code>Rack::MockRequest</code></a> helps testing your <a href="../Rack.html"><code>Rack</code></a> application without actually using HTTP.</p> <p>After performing a request on a URL with get/post/put/patch/delete, it returns a <a href="MockResponse.html"><code>MockResponse</code></a> with useful helper methods for effective testing.</p> <p>You can pass a hash with additional configuration to the get/post/put/patch/delete.</p> <dl class="rdoc-list note-list"><dt><code>:input</code> <dd> <p>A String or IO-like to be used as rack.input.</p> </dd><dt><code>:fatal</code> <dd> <p>Raise a <a href="MockRequest/FatalWarning.html"><code>FatalWarning</code></a> if the app writes to rack.errors.</p> </dd><dt><code>:lint</code> <dd> <p>If true, wrap the application in a <a href="Lint.html"><code>Rack::Lint</code></a>.</p> </dd></dl> </section> <section id="5Buntitled-5D" class="documentation-section"> <section class="constants-list"> <header> <h3>Constants</h3> </header> <dl> <dt id="DEFAULT_ENV">DEFAULT_ENV <dd> </dl> </section> <section id="public-class-5Buntitled-5D-method-details" class="method-section"> <header> <h3>Public Class Methods</h3> </header> <div id="method-c-env_for" class="method-detail "> <div class="method-heading"> <span class="method-name">env_for</span><span class="method-args">(uri = "", opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Return the <a href="../Rack.html"><code>Rack</code></a> environment used for a request to <code>uri</code>. All options that are strings are added to the returned environment. Options:</p> <dl class="rdoc-list note-list"><dt>:fatal <dd> <p>Whether to raise an exception if request outputs to rack.errors</p> </dd><dt>:input <dd> <p>The rack.input to set</p> </dd><dt>:method <dd> <p>The HTTP request method to use</p> </dd><dt>:params <dd> <p>The params to use</p> </dd><dt>:script_name <dd> <p>The SCRIPT_NAME to set</p> </dd></dl> <div class="method-source-code" id="env_for-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 105</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">env_for</span>(<span class="ruby-identifier">uri</span> = <span class="ruby-string">""</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">uri</span> = <span class="ruby-identifier">parse_uri_rfc2396</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> = <span class="ruby-node">"/#{uri.path}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-value">?/</span> <span class="ruby-identifier">env</span> = <span class="ruby-constant">DEFAULT_ENV</span>.<span class="ruby-identifier">dup</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">REQUEST_METHOD</span>] = (<span class="ruby-identifier">opts</span>[<span class="ruby-value">:method</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:method</span>].<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span> <span class="ruby-operator">:</span> <span class="ruby-constant">GET</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">SERVER_NAME</span>] = (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">host</span> <span class="ruby-operator">||</span> <span class="ruby-string">"example.org"</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">SERVER_PORT</span>] = (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">port</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-string">"80"</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>] = (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">PATH_INFO</span>] = ((<span class="ruby-operator">!</span><span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-string">"/"</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">uri</span>.<span class="ruby-identifier">path</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_URL_SCHEME</span>] = (<span class="ruby-identifier">uri</span>.<span class="ruby-identifier">scheme</span> <span class="ruby-operator">||</span> <span class="ruby-string">"http"</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTPS</span>] = (<span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_URL_SCHEME</span>] <span class="ruby-operator">==</span> <span class="ruby-string">"https"</span> <span class="ruby-operator">?</span> <span class="ruby-string">"on"</span> <span class="ruby-operator">:</span> <span class="ruby-string">"off"</span>).<span class="ruby-identifier">b</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">SCRIPT_NAME</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:script_name</span>] <span class="ruby-operator">||</span> <span class="ruby-string">""</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:fatal</span>] <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_ERRORS</span>] = <span class="ruby-constant">FatalWarner</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_ERRORS</span>] = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:params</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">REQUEST_METHOD</span>] <span class="ruby-operator">==</span> <span class="ruby-constant">GET</span> <span class="ruby-identifier">params</span> = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">parse_nested_query</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>) <span class="ruby-identifier">params</span>.<span class="ruby-identifier">update</span>(<span class="ruby-constant">Utils</span>.<span class="ruby-identifier">parse_nested_query</span>(<span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>])) <span class="ruby-identifier">env</span>[<span class="ruby-constant">QUERY_STRING</span>] = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">elsif</span> <span class="ruby-operator">!</span><span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:input</span>) <span class="ruby-identifier">opts</span>[<span class="ruby-string">"CONTENT_TYPE"</span>] = <span class="ruby-string">"application/x-www-form-urlencoded"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Multipart</span>.<span class="ruby-identifier">build_multipart</span>(<span class="ruby-identifier">params</span>) <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] = <span class="ruby-identifier">data</span> <span class="ruby-identifier">opts</span>[<span class="ruby-string">"CONTENT_LENGTH"</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-identifier">opts</span>[<span class="ruby-string">"CONTENT_TYPE"</span>] = <span class="ruby-node">"multipart/form-data; boundary=#{Rack::Multipart::MULTIPART_BOUNDARY}"</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] = <span class="ruby-constant">Utils</span>.<span class="ruby-identifier">build_nested_query</span>(<span class="ruby-identifier">params</span>) <span class="ruby-keyword">end</span> <span class="ruby-keyword">else</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] = <span class="ruby-identifier">params</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">empty_str</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">empty_str</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] <span class="ruby-identifier">rack_input</span> = <span class="ruby-constant">StringIO</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>]) <span class="ruby-keyword">else</span> <span class="ruby-identifier">rack_input</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:input</span>] <span class="ruby-keyword">end</span> <span class="ruby-identifier">rack_input</span>.<span class="ruby-identifier">set_encoding</span>(<span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">BINARY</span>) <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_INPUT</span>] = <span class="ruby-identifier">rack_input</span> <span class="ruby-identifier">env</span>[<span class="ruby-string">"CONTENT_LENGTH"</span>] <span class="ruby-operator">||=</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_INPUT</span>].<span class="ruby-identifier">size</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_INPUT</span>].<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:size</span>) <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">field</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">env</span>[<span class="ruby-identifier">field</span>] = <span class="ruby-identifier">value</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">String</span> <span class="ruby-operator">===</span> <span class="ruby-identifier">field</span> } <span class="ruby-identifier">env</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-c-new" class="method-detail "> <div class="method-heading"> <span class="method-name">new</span><span class="method-args">(app)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="new-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 52</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">app</span>) <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-c-parse_uri_rfc2396" class="method-detail "> <div class="method-heading"> <span class="method-name">parse_uri_rfc2396</span><span class="method-args">(uri)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>For historical reasons, we're pinning to RFC 2396. URI::Parser = URI::RFC2396_Parser</p> <div class="method-source-code" id="parse_uri_rfc2396-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 92</span> <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse_uri_rfc2396</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-ivar">@parser</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">URI</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">uri</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> </section> <section id="public-instance-5Buntitled-5D-method-details" class="method-section"> <header> <h3>Public Instance Methods</h3> </header> <div id="method-i-delete" class="method-detail "> <div class="method-heading"> <span class="method-name">delete</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a DELETE request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="delete-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 65</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">delete</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">DELETE</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-get" class="method-detail "> <div class="method-heading"> <span class="method-name">get</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a GET request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="get-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 57</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">GET</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-head" class="method-detail "> <div class="method-heading"> <span class="method-name">head</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a HEAD request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="head-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 67</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">head</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">HEAD</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-options" class="method-detail "> <div class="method-heading"> <span class="method-name">options</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make an OPTIONS request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="options-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 69</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">options</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">OPTIONS</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-patch" class="method-detail "> <div class="method-heading"> <span class="method-name">patch</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a PATCH request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="patch-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 63</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">patch</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">PATCH</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-post" class="method-detail "> <div class="method-heading"> <span class="method-name">post</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a POST request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="post-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 59</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">post</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">POST</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-put" class="method-detail "> <div class="method-heading"> <span class="method-name">put</span><span class="method-args">(uri, opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a PUT request and return a <a href="MockResponse.html"><code>MockResponse</code></a>. See <a href="MockRequest.html#method-i-request"><code>request</code></a>.</p> <div class="method-source-code" id="put-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 61</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">put</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">request</span>(<span class="ruby-constant">PUT</span>, <span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-request" class="method-detail "> <div class="method-heading"> <span class="method-name">request</span><span class="method-args">(method = GET, uri = "", opts = {})</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <p>Make a request using the given request method for the given uri to the rack application and return a <a href="MockResponse.html"><code>MockResponse</code></a>. Options given are passed to <a href="MockRequest.html#method-c-env_for"><code>MockRequest.env_for</code></a>.</p> <div class="method-source-code" id="request-source"> <pre><span class="ruby-comment"># File lib/rack/mock.rb, line 74</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">request</span>(<span class="ruby-identifier">method</span> = <span class="ruby-constant">GET</span>, <span class="ruby-identifier">uri</span> = <span class="ruby-string">""</span>, <span class="ruby-identifier">opts</span> = {}) <span class="ruby-identifier">env</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">env_for</span>(<span class="ruby-identifier">uri</span>, <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-value">method:</span> <span class="ruby-identifier">method</span>)) <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:lint</span>] <span class="ruby-identifier">app</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Lint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@app</span>) <span class="ruby-keyword">else</span> <span class="ruby-identifier">app</span> = <span class="ruby-ivar">@app</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">errors</span> = <span class="ruby-identifier">env</span>[<span class="ruby-constant">RACK_ERRORS</span>] <span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>) <span class="ruby-constant">MockResponse</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">status</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">body</span>, <span class="ruby-identifier">errors</span>) <span class="ruby-keyword">ensure</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">body</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:close</span>) <span class="ruby-keyword">end</span></pre> </div> </div> </div> </section> </section> </main> <footer id="validator-badges" role="contentinfo"> <p><a href="https://validator.w3.org/check/referer">Validate</a> <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1. <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>. </footer>