5 # These methods are for integration testing without an internet connection. They are available in Test::Unit::TestCase and when in Irb.
10 # get_it, post_it, put_it, delete_it
11 # Executes the method and returns the result of the body
14 # +:params+ a hash of name parameters
17 # get_it '/', :name => 'Blake' # => 'Hello Blake!'
19 %w(get post put delete).each do |verb|
20 module_eval <<-end_eval
21 def #{verb}_it(path, params = {})
22 request = Rack::MockRequest.new(Sinatra::Dispatcher.new)
23 @response = request.#{verb} path, :input => generate_input(params)
29 # The response returned by the Event
31 @response || Rack::MockResponse.new(404, {}, '')
34 # The status returned by the event
39 # The text returned by the event
47 # The headers returned by the event
54 def generate_input(params)
55 params.map { |k,v| "#{k}=#{URI.escape(v)}" }.join('&')