Use MerbSession instead of re-opening Session when loading merb support
This commit is contained in:
parent
56e02cfdf3
commit
ff3e869776
|
@ -5,7 +5,7 @@ module Webrat
|
||||||
meths.each do |meth|
|
meths.each do |meth|
|
||||||
self.class_eval <<-RUBY
|
self.class_eval <<-RUBY
|
||||||
def #{meth}(*args, &blk)
|
def #{meth}(*args, &blk)
|
||||||
@session ||= ::Webrat::Session.new
|
@session ||= ::Webrat::MerbSession.new
|
||||||
@session.#{meth}(*args, &blk)
|
@session.#{meth}(*args, &blk)
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
|
|
|
@ -8,7 +8,7 @@ require "merb-core"
|
||||||
HashWithIndifferentAccess = Mash
|
HashWithIndifferentAccess = Mash
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class Session
|
class MerbSession < Session
|
||||||
include Merb::Test::MakeRequest
|
include Merb::Test::MakeRequest
|
||||||
|
|
||||||
attr_accessor :response
|
attr_accessor :response
|
||||||
|
@ -55,7 +55,7 @@ module Merb
|
||||||
module Test
|
module Test
|
||||||
module RequestHelper
|
module RequestHelper
|
||||||
def request(uri, env = {})
|
def request(uri, env = {})
|
||||||
@session ||= Webrat::Session.new
|
@session ||= Webrat::MerbSession.new
|
||||||
@session.response = @session.request(uri, env)
|
@session.response = @session.request(uri, env)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ end
|
||||||
|
|
||||||
class Merb::Test::RspecStory
|
class Merb::Test::RspecStory
|
||||||
def browser
|
def browser
|
||||||
@browser ||= Webrat::Session.new
|
@browser ||= Webrat::MerbSession.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + "/helper")
|
||||||
describe Webrat::Session do
|
describe Webrat::Session do
|
||||||
|
|
||||||
it "should not pass empty params if data is and empty hash" 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 = OpenStruct.new
|
||||||
response.status = 200
|
response.status = 200
|
||||||
session.should_receive(:request).with('url', {:params=> nil, :method=>"GET", :headers=>nil}).and_return(response)
|
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|
|
%w{post put delete}.each do |request_method|
|
||||||
it "should call do request with method #{request_method.upcase} for a #{request_method} call" do
|
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 = OpenStruct.new
|
||||||
response.status = 200
|
response.status = 200
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ describe Webrat::Session do
|
||||||
context "a session with a response" do
|
context "a session with a response" do
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
@session = Webrat::Session.new
|
@session = Webrat::MerbSession.new
|
||||||
@response = OpenStruct.new
|
@response = OpenStruct.new
|
||||||
@response.status = 200
|
@response.status = 200
|
||||||
@response.body = 'test response'
|
@response.body = 'test response'
|
||||||
|
|
Loading…
Reference in New Issue