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