Skip to content

Commit

Permalink
Use MerbSession instead of re-opening Session when loading merb support
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Nov 7, 2008
1 parent 56e02cf commit ff3e869
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/webrat/core/methods.rb
Expand Up @@ -5,7 +5,7 @@ def self.delegate_to_session(*meths)
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
Expand Down
6 changes: 3 additions & 3 deletions lib/webrat/merb.rb
Expand Up @@ -8,7 +8,7 @@
HashWithIndifferentAccess = Mash

module Webrat
class Session
class MerbSession < Session
include Merb::Test::MakeRequest

attr_accessor :response
Expand Down Expand Up @@ -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

Expand All @@ -68,7 +68,7 @@ def follow_redirect

class Merb::Test::RspecStory
def browser
@browser ||= Webrat::Session.new
@browser ||= Webrat::MerbSession.new
end
end

6 changes: 3 additions & 3 deletions spec/webrat/merb/session_spec.rb
Expand Up @@ -4,7 +4,7 @@
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)
Expand All @@ -13,7 +13,7 @@

%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

Expand All @@ -25,7 +25,7 @@
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'
Expand Down

0 comments on commit ff3e869

Please sign in to comment.