From 176a851c9c35cca105023dd4796760297947a881 Mon Sep 17 00:00:00 2001 From: Jonas Nicklas and Kevin Fitzpatrick Date: Wed, 4 Nov 2009 23:05:11 +0100 Subject: [PATCH] Renamed get to visit --- lib/webcat.rb | 22 +--------------------- lib/webcat/culerity_driver.rb | 2 +- lib/webcat/rack_test_driver.rb | 4 ++++ lib/webcat/session.rb | 20 ++++++++++++++++++++ spec/drivers_spec.rb | 4 ++-- spec/webcat_spec.rb | 6 +++--- 6 files changed, 31 insertions(+), 27 deletions(-) create mode 100644 lib/webcat/session.rb diff --git a/lib/webcat.rb b/lib/webcat.rb index b2821c97..d4d7f2fc 100644 --- a/lib/webcat.rb +++ b/lib/webcat.rb @@ -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' diff --git a/lib/webcat/culerity_driver.rb b/lib/webcat/culerity_driver.rb index 8050f9d3..a5bab9c3 100644 --- a/lib/webcat/culerity_driver.rb +++ b/lib/webcat/culerity_driver.rb @@ -13,7 +13,7 @@ class Webcat::Driver::Culerity @rack_server.boot end - def get(path) + def visit(path) browser.goto(url(path)) end diff --git a/lib/webcat/rack_test_driver.rb b/lib/webcat/rack_test_driver.rb index 76faedd1..58ac2921 100644 --- a/lib/webcat/rack_test_driver.rb +++ b/lib/webcat/rack_test_driver.rb @@ -11,6 +11,10 @@ class Webcat::Driver::RackTest @app = app end + def visit(path) + get(path) + end + def body response.body end diff --git a/lib/webcat/session.rb b/lib/webcat/session.rb new file mode 100644 index 00000000..b3e4836c --- /dev/null +++ b/lib/webcat/session.rb @@ -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 \ No newline at end of file diff --git a/spec/drivers_spec.rb b/spec/drivers_spec.rb index 975ce0aa..bd48d678 100644 --- a/spec/drivers_spec.rb +++ b/spec/drivers_spec.rb @@ -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 diff --git a/spec/webcat_spec.rb b/spec/webcat_spec.rb index a7ba8a30..8390e969 100644 --- a/spec/webcat_spec.rb +++ b/spec/webcat_spec.rb @@ -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