Use MerbSession instead of re-opening Session when loading merb support

This commit is contained in:
Bryan Helmkamp 2008-11-07 11:33:51 -05:00
parent 56e02cfdf3
commit ff3e869776
3 changed files with 7 additions and 7 deletions

View File

@ -5,7 +5,7 @@ module Webrat
meths.each do |meth|
self.class_eval <<-RUBY
def #{meth}(*args, &blk)
@session ||= ::Webrat::Session.new
@session ||= ::Webrat::MerbSession.new
@session.#{meth}(*args, &blk)
end
RUBY

View File

@ -8,7 +8,7 @@ require "merb-core"
HashWithIndifferentAccess = Mash
module Webrat
class Session
class MerbSession < Session
include Merb::Test::MakeRequest
attr_accessor :response
@ -55,7 +55,7 @@ module Merb
module Test
module RequestHelper
def request(uri, env = {})
@session ||= Webrat::Session.new
@session ||= Webrat::MerbSession.new
@session.response = @session.request(uri, env)
end
@ -68,7 +68,7 @@ end
class Merb::Test::RspecStory
def browser
@browser ||= Webrat::Session.new
@browser ||= Webrat::MerbSession.new
end
end

View File

@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + "/helper")
describe Webrat::Session do
it "should not pass empty params if data is and empty hash" do
session = Webrat::Session.new
session = Webrat::MerbSession.new
response = OpenStruct.new
response.status = 200
session.should_receive(:request).with('url', {:params=> nil, :method=>"GET", :headers=>nil}).and_return(response)
@ -13,7 +13,7 @@ describe Webrat::Session do
%w{post put delete}.each do |request_method|
it "should call do request with method #{request_method.upcase} for a #{request_method} call" do
session = Webrat::Session.new
session = Webrat::MerbSession.new
response = OpenStruct.new
response.status = 200
@ -25,7 +25,7 @@ describe Webrat::Session do
context "a session with a response" do
setup do
@session = Webrat::Session.new
@session = Webrat::MerbSession.new
@response = OpenStruct.new
@response.status = 200
@response.body = 'test response'