Merge commit '1bfe7634f8bb93472f4f53715d43916a8ff1569f'
This commit is contained in:
commit
d60f524df1
@ -1,6 +1,6 @@
|
|||||||
require 'webrat/rack'
|
require 'webrat/rack'
|
||||||
require 'sinatra'
|
require 'sinatra'
|
||||||
require 'sinatra/test/methods'
|
require 'sinatra/test'
|
||||||
|
|
||||||
class Sinatra::Application
|
class Sinatra::Application
|
||||||
# Override this to prevent Sinatra from barfing on the options passed from RSpec
|
# Override this to prevent Sinatra from barfing on the options passed from RSpec
|
||||||
@ -11,18 +11,20 @@ end
|
|||||||
disable :run
|
disable :run
|
||||||
disable :reload
|
disable :reload
|
||||||
|
|
||||||
|
require 'ruby-debug'
|
||||||
module Webrat
|
module Webrat
|
||||||
class SinatraSession < RackSession #:nodoc:
|
class SinatraSession < RackSession #:nodoc:
|
||||||
include Sinatra::Test::Methods
|
include Sinatra::Test
|
||||||
|
|
||||||
attr_reader :request, :response
|
attr_reader :request, :response
|
||||||
|
|
||||||
%w(get head post put delete).each do |verb|
|
%w(get head post put delete).each do |verb|
|
||||||
|
alias_method "orig_#{verb}", verb
|
||||||
define_method(verb) do |*args| # (path, data, headers = nil)
|
define_method(verb) do |*args| # (path, data, headers = nil)
|
||||||
path, data, headers = *args
|
path, data, headers = *args
|
||||||
data = data.inject({}) {|data, (key,value)| data[key] = Rack::Utils.unescape(value); data }
|
data = data.inject({}) {|data, (key,value)| data[key] = Rack::Utils.unescape(value); data }
|
||||||
params = data.merge(:env => headers || {})
|
params = data.merge(:env => headers || {})
|
||||||
self.__send__("#{verb}_it", path, params)
|
self.__send__("orig_#{verb}", path, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,23 +6,23 @@ describe Webrat::SinatraSession, "API" do
|
|||||||
@sinatra_session = Webrat::SinatraSession.new
|
@sinatra_session = Webrat::SinatraSession.new
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should delegate get to get_it" do
|
it "should delegate get to sinatras get" do
|
||||||
@sinatra_session.should_receive(:get_it).with("url", { :env => "headers" })
|
@sinatra_session.should_receive(:orig_get).with("url", { :env => "headers" })
|
||||||
@sinatra_session.get("url", {}, "headers")
|
@sinatra_session.get("url", {}, "headers")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should delegate post to post_it" do
|
it "should delegate post to sinatras post" do
|
||||||
@sinatra_session.should_receive(:post_it).with("url", { :env => "headers" })
|
@sinatra_session.should_receive(:orig_post).with("url", { :env => "headers" })
|
||||||
@sinatra_session.post("url", {}, "headers")
|
@sinatra_session.post("url", {}, "headers")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should delegate put to put_it" do
|
it "should delegate put to sinatras put" do
|
||||||
@sinatra_session.should_receive(:put_it).with("url", { :env => "headers" })
|
@sinatra_session.should_receive(:orig_put).with("url", { :env => "headers" })
|
||||||
@sinatra_session.put("url", {}, "headers")
|
@sinatra_session.put("url", {}, "headers")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should delegate delete to delete_it" do
|
it "should delegate delete to sinatras delete" do
|
||||||
@sinatra_session.should_receive(:delete_it).with("url", { :env => "headers" })
|
@sinatra_session.should_receive(:orig_delete).with("url", { :env => "headers" })
|
||||||
@sinatra_session.delete("url", {}, "headers")
|
@sinatra_session.delete("url", {}, "headers")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user