Sha256: a0313a36169ae4fe0dc320c445410e23181e4e328a65cb152fbcf30c8c127db1
Contents?: true
Size: 948 Bytes
Versions: 3
Compression:
Stored size: 948 Bytes
Contents
module Tap module Mechanize module Test # MockServer allows easy creation of a lazy Rack application that calls # the block for content. The status and headers of the response are # setup during initialize. # # env = Rack::MockRequest.env_for('http://localhost:2000/') # # m = MockServer.new {|env| ['yo'] } # m.call(env) # => [200, {'Content-Type' => 'text/html'}, ['yo']] # class MockServer def initialize(status=200, headers={'Content-Type' => 'text/html'}, &block) @status = status @headers = headers @block = block end # Calls the initialization block with env. The block must return the # content of the response. # # Returns: [status, headers, block-return] def call(env) [@status, @headers, @block.call(env)] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tap-mechanize-0.5.0 | lib/tap/mechanize/test/mock_server.rb |
tap-mechanize-0.5.1 | lib/tap/mechanize/test/mock_server.rb |
tap-mechanize-0.6.0 | lib/tap/mechanize/test/mock_server.rb |