5 # These methods are for integration testing without an internet connection. They are available in Test::Unit::TestCase and when in Irb.
11 # get_it, post_it, put_it, delete_it
12 # Executes the method and returns the result of the body
15 # +:params+ a hash of name parameters
18 # get_it '/', :name => 'Blake' # => 'Hello Blake!'
20 %w(get post put delete).each do |verb|
21 module_eval <<-end_eval
22 def #{verb}_it(path, params = {})
23 request = Rack::MockRequest.new(Sinatra::Dispatcher.new)
24 @response = request.#{verb} path, :input => generate_input(params)
31 @response || Rack::MockResponse.new(404, {}, '')
51 def generate_input(params)
52 params.map { |k,v| "#{k}=#{URI.escape(v)}" }.join('&')