Deprecate the :sinatra mode
* I took the conservative approach here: the sinatra code could be removed but that'd cause a regression. (using Sinatra::Application when `app` is not defined) * I left the sinatra tests for now; they should be removed once we're fully confident with rack session ones.
This commit is contained in:
parent
051dfe188c
commit
a5a91b32e9
@ -18,14 +18,17 @@ module Webrat
|
||||
RailsSession
|
||||
when :merb
|
||||
MerbSession
|
||||
when :rack
|
||||
RackSession
|
||||
when :sinatra
|
||||
warn("The :sinatra mode is deprecated. Please use :rack instead")
|
||||
SinatraSession
|
||||
when :selenium
|
||||
SeleniumSession
|
||||
when :sinatra
|
||||
SinatraSession
|
||||
when :mechanize
|
||||
MechanizeSession
|
||||
when :rack
|
||||
RackSession
|
||||
else
|
||||
raise WebratError.new(<<-STR)
|
||||
Unknown Webrat mode: #{Webrat.configuration.mode.inspect}
|
||||
|
@ -1,41 +1,11 @@
|
||||
require "webrat/rack"
|
||||
require "sinatra/test"
|
||||
|
||||
module Webrat
|
||||
class SinatraSession
|
||||
include Sinatra::Test
|
||||
|
||||
class SinatraSession < RackSession
|
||||
def initialize(context)
|
||||
app = context.respond_to?(:app) ? context.app : Sinatra::Application
|
||||
|
||||
@browser = Sinatra::TestHarness.new(app)
|
||||
end
|
||||
|
||||
%w(get head post put delete).each do |verb|
|
||||
class_eval <<-RUBY
|
||||
def #{verb}(path, data, headers = {})
|
||||
params = data.inject({}) do |data, (key,value)|
|
||||
data[key] = Rack::Utils.unescape(value)
|
||||
data
|
||||
end
|
||||
headers["HTTP_HOST"] = "www.example.com"
|
||||
@browser.#{verb}(path, params, headers)
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
||||
def response_body
|
||||
@browser.body
|
||||
end
|
||||
|
||||
def response_code
|
||||
@browser.response.status
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def response
|
||||
@browser.response
|
||||
super(Rack::Test::Session.new(app))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user