public
Description: Webrat - Ruby Acceptance Testing for Web applications
Homepage: http://gitrdoc.com/brynary/webrat/tree/master/
Clone URL: git://github.com/brynary/webrat.git
webrat / lib / webrat / sinatra.rb
100644 21 lines (17 sloc) 0.558 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'webrat/rack'
require 'sinatra'
require 'sinatra/test/methods'
 
module Webrat
  class SinatraSession < RackSession #:nodoc:
    include Sinatra::Test::Methods
    
    attr_reader :request, :response
 
    %w(get head post put delete).each do |verb|
      define_method(verb) do |*args| # (path, data, headers = nil)
        path, data, headers = *args
        params = data.merge(:env => headers || {})
        self.__send__("#{verb}_it", path, params)
        get_it(@response.location, params) while @response.redirect?
      end
    end
  end
end