mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Renamed get to visit
This commit is contained in:
parent
8435d19a3a
commit
176a851c9c
6 changed files with 31 additions and 27 deletions
|
@ -7,28 +7,8 @@ module Webcat
|
|||
end
|
||||
end
|
||||
|
||||
class Session
|
||||
attr_reader :mode, :app
|
||||
|
||||
def initialize(mode, app)
|
||||
@mode = mode
|
||||
@app = app
|
||||
end
|
||||
|
||||
def driver
|
||||
@driver ||= Webcat::Driver::RackTest.new(app)
|
||||
end
|
||||
|
||||
def get(path)
|
||||
driver.get(path)
|
||||
end
|
||||
|
||||
def body
|
||||
driver.response.body
|
||||
end
|
||||
end
|
||||
|
||||
autoload :Server, 'webcat/server'
|
||||
autoload :Session, 'webcat/session'
|
||||
|
||||
module Driver
|
||||
autoload :RackTest, 'webcat/rack_test_driver'
|
||||
|
|
|
@ -13,7 +13,7 @@ class Webcat::Driver::Culerity
|
|||
@rack_server.boot
|
||||
end
|
||||
|
||||
def get(path)
|
||||
def visit(path)
|
||||
browser.goto(url(path))
|
||||
end
|
||||
|
||||
|
|
|
@ -11,6 +11,10 @@ class Webcat::Driver::RackTest
|
|||
@app = app
|
||||
end
|
||||
|
||||
def visit(path)
|
||||
get(path)
|
||||
end
|
||||
|
||||
def body
|
||||
response.body
|
||||
end
|
||||
|
|
20
lib/webcat/session.rb
Normal file
20
lib/webcat/session.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class Webcat::Session
|
||||
attr_reader :mode, :app
|
||||
|
||||
def initialize(mode, app)
|
||||
@mode = mode
|
||||
@app = app
|
||||
end
|
||||
|
||||
def driver
|
||||
@driver ||= Webcat::Driver::RackTest.new(app)
|
||||
end
|
||||
|
||||
def visit(path)
|
||||
driver.visit(path)
|
||||
end
|
||||
|
||||
def body
|
||||
driver.response.body
|
||||
end
|
||||
end
|
|
@ -4,9 +4,9 @@ shared_examples_for 'driver' do
|
|||
|
||||
describe '#get' do
|
||||
it "should fetch a response" do
|
||||
@driver.get('/')
|
||||
@driver.visit('/')
|
||||
@driver.body.should == 'Hello world!'
|
||||
@driver.get('/foo')
|
||||
@driver.visit('/foo')
|
||||
@driver.body.should == 'Another World'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,11 +23,11 @@ describe Webcat::Session do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#get' do
|
||||
describe '#visit' do
|
||||
it "should fetch a response from the driver" do
|
||||
@session.get('/')
|
||||
@session.visit('/')
|
||||
@session.body.should == 'Hello world!'
|
||||
@session.get('/foo')
|
||||
@session.visit('/foo')
|
||||
@session.body.should == 'Another World'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue