Rename RailsSession to RailsAdapter

This commit is contained in:
Bryan Helmkamp 2009-08-12 20:52:57 -04:00
parent 986682488e
commit 89ec303db5
3 changed files with 16 additions and 16 deletions

View File

@ -19,7 +19,7 @@ module Webrat
def self.adapter_class def self.adapter_class
case Webrat.configuration.mode case Webrat.configuration.mode
when :rails when :rails
RailsSession RailsAdapter
when :merb when :merb
MerbAdapter MerbAdapter
when :rack when :rack

View File

@ -5,7 +5,7 @@ require "action_controller/integration"
require "action_controller/record_identifier" require "action_controller/record_identifier"
module Webrat module Webrat
class RailsSession #:nodoc: class RailsAdapter #:nodoc:
include ActionController::RecordIdentifier include ActionController::RecordIdentifier
attr_reader :integration_session attr_reader :integration_session

View File

@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require "webrat/rails" require "webrat/rails"
describe Webrat::RailsSession do describe Webrat::RailsAdapter do
before :each do before :each do
Webrat.configuration.mode = :rails Webrat.configuration.mode = :rails
@integration_session = mock("integration_session") @integration_session = mock("integration_session")
@ -10,35 +10,35 @@ describe Webrat::RailsSession do
it "should delegate response_body to the session response body" do it "should delegate response_body to the session response body" do
@integration_session.stub!(:response => mock("response", :body => "<html>")) @integration_session.stub!(:response => mock("response", :body => "<html>"))
Webrat::RailsSession.new(@integration_session).response_body.should == "<html>" Webrat::RailsAdapter.new(@integration_session).response_body.should == "<html>"
end end
it "should delegate response_code to the session response code" do it "should delegate response_code to the session response code" do
@integration_session.stub!(:response => mock("response", :code => "42")) @integration_session.stub!(:response => mock("response", :code => "42"))
Webrat::RailsSession.new(@integration_session).response_code.should == 42 Webrat::RailsAdapter.new(@integration_session).response_code.should == 42
end end
it "should delegate get to the integration session" do it "should delegate get to the integration session" do
@integration_session.should_receive(:get).with("url", "data", "headers") @integration_session.should_receive(:get).with("url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.get("url", "data", "headers") rails_session.get("url", "data", "headers")
end end
it "should delegate post to the integration session" do it "should delegate post to the integration session" do
@integration_session.should_receive(:post).with("url", "data", "headers") @integration_session.should_receive(:post).with("url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.post("url", "data", "headers") rails_session.post("url", "data", "headers")
end end
it "should delegate put to the integration session" do it "should delegate put to the integration session" do
@integration_session.should_receive(:put).with("url", "data", "headers") @integration_session.should_receive(:put).with("url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.put("url", "data", "headers") rails_session.put("url", "data", "headers")
end end
it "should delegate delete to the integration session" do it "should delegate delete to the integration session" do
@integration_session.should_receive(:delete).with("url", "data", "headers") @integration_session.should_receive(:delete).with("url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.delete("url", "data", "headers") rails_session.delete("url", "data", "headers")
end end
@ -46,7 +46,7 @@ describe Webrat::RailsSession do
it "should pass the full url" do it "should pass the full url" do
@integration_session.stub!(:https!) @integration_session.stub!(:https!)
@integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers") @integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.get("http://www.example.com/url", "data", "headers") rails_session.get("http://www.example.com/url", "data", "headers")
end end
end end
@ -55,7 +55,7 @@ describe Webrat::RailsSession do
it "should call #https! with true before the request before passing along the full url" do it "should call #https! with true before the request before passing along the full url" do
@integration_session.should_receive(:https!).with(true) @integration_session.should_receive(:https!).with(true)
@integration_session.should_receive(:get).with("https://www.example.com/url", "data", "headers") @integration_session.should_receive(:get).with("https://www.example.com/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.get("https://www.example.com/url", "data", "headers") rails_session.get("https://www.example.com/url", "data", "headers")
end end
end end
@ -64,7 +64,7 @@ describe Webrat::RailsSession do
it "should call #https! with true before the request" do it "should call #https! with true before the request" do
@integration_session.stub!(:get) @integration_session.stub!(:get)
@integration_session.should_receive(:https!).with(false) @integration_session.should_receive(:https!).with(false)
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.get("http://www.example.com/url", "data", "headers") rails_session.get("http://www.example.com/url", "data", "headers")
end end
end end
@ -73,17 +73,17 @@ describe Webrat::RailsSession do
it "should strip out the anchor" do it "should strip out the anchor" do
@integration_session.should_receive(:https!).with(false) @integration_session.should_receive(:https!).with(false)
@integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers") @integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
rails_session.get("http://www.example.com/url#foo", "data", "headers") rails_session.get("http://www.example.com/url#foo", "data", "headers")
end end
end end
it "should provide a saved_page_dir" do it "should provide a saved_page_dir" do
Webrat::RailsSession.new(mock("integration session")).should respond_to(:saved_page_dir) Webrat::RailsAdapter.new(mock("integration session")).should respond_to(:saved_page_dir)
end end
it "should provide a doc_root" do it "should provide a doc_root" do
Webrat::RailsSession.new(mock("integration session")).should respond_to(:doc_root) Webrat::RailsAdapter.new(mock("integration session")).should respond_to(:doc_root)
end end
it "should accept an ActiveRecord argument to #within and translate to a selector using dom_id" do it "should accept an ActiveRecord argument to #within and translate to a selector using dom_id" do
@ -100,7 +100,7 @@ describe Webrat::RailsSession do
@integration_session.stub!(:response => response) @integration_session.stub!(:response => response)
@integration_session.should_receive(:get).with("/page2", {}, nil) @integration_session.should_receive(:get).with("/page2", {}, nil)
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsAdapter.new(@integration_session)
object = Object.new object = Object.new
object.stub!(:id => nil) object.stub!(:id => nil)