Decouple from Rails so we can use Webrat with Sinatra
This commit is contained in:
parent
89d56fb5da
commit
682f4d19f9
@ -3,7 +3,6 @@ module Webrat
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "active_support"
|
||||
|
||||
require File.dirname(__FILE__) + "/webrat/core"
|
||||
require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV)
|
||||
|
@ -106,11 +106,13 @@ module Webrat
|
||||
def form_action
|
||||
@element["action"].blank? ? @session.current_url : @element["action"]
|
||||
end
|
||||
|
||||
HASH = [Hash, HashWithIndifferentAccess] rescue [Hash]
|
||||
|
||||
def merge(all_params, new_param)
|
||||
new_param.each do |key, value|
|
||||
case all_params[key]
|
||||
when Hash, HashWithIndifferentAccess
|
||||
when *HASH
|
||||
merge_hash_values(all_params[key], value)
|
||||
when Array
|
||||
all_params[key] += value
|
||||
|
@ -1,5 +1,16 @@
|
||||
require 'webrat'
|
||||
|
||||
class CGIMethods
|
||||
def self.parse_query_parameters(params)
|
||||
hash = {}
|
||||
params.split('&').each do |p|
|
||||
pair = p.split('=')
|
||||
hash[pair[0]] = pair[1]
|
||||
end
|
||||
hash
|
||||
end
|
||||
end
|
||||
|
||||
module Webrat
|
||||
class RackSession < Session
|
||||
def response_body
|
||||
|
@ -6,8 +6,12 @@ module Webrat
|
||||
class SinatraSession < RackSession
|
||||
include Sinatra::Test::Methods
|
||||
|
||||
def get(*args)
|
||||
get_it(*args)
|
||||
def get(url, data, headers = nil)
|
||||
get_it(url, data)
|
||||
end
|
||||
|
||||
def post(url, data, headers = nil)
|
||||
post_it(url, data)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user