mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
DSL only has a single app
Just makes more sense
This commit is contained in:
parent
67cddc7008
commit
eef4e74a9f
2 changed files with 9 additions and 11 deletions
|
@ -2,6 +2,8 @@ module Webcat
|
|||
class << self
|
||||
attr_writer :default_driver, :current_driver
|
||||
|
||||
attr_accessor :app
|
||||
|
||||
def default_driver
|
||||
@default_driver || :rack_test
|
||||
end
|
||||
|
@ -15,6 +17,12 @@ module Webcat
|
|||
@current_driver = nil
|
||||
end
|
||||
|
||||
def current_session
|
||||
session_pool["#{current_driver}#{app.object_id}"] ||= Webcat::Session.new(current_driver, app)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def session_pool
|
||||
@session_pool ||= {}
|
||||
end
|
||||
|
@ -22,12 +30,6 @@ module Webcat
|
|||
|
||||
extend(self)
|
||||
|
||||
attr_accessor :app
|
||||
|
||||
def current_session
|
||||
driver = Webcat.current_driver
|
||||
Webcat.session_pool["#{driver}#{app.object_id}"] ||= Webcat::Session.new(driver, app)
|
||||
end
|
||||
|
||||
SESSION_METHODS = [
|
||||
:visit, :body, :click_link, :click_button, :fill_in, :choose,
|
||||
|
@ -36,7 +38,7 @@ module Webcat
|
|||
SESSION_METHODS.each do |method|
|
||||
class_eval <<-RUBY, __FILE__, __LINE__+1
|
||||
def #{method}(*args, &block)
|
||||
current_session.#{method}(*args, &block)
|
||||
Webcat.current_session.#{method}(*args, &block)
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
|
|
@ -100,13 +100,9 @@ describe Webcat do
|
|||
include Webcat
|
||||
end
|
||||
foo = klass.new
|
||||
foo.app = TestApp
|
||||
foo.visit('/with_html')
|
||||
foo.click_link('ullamco')
|
||||
foo.body.should include('Another World')
|
||||
foo.app = proc { [200, {}, "Another Application"] }
|
||||
foo.visit('/')
|
||||
foo.body.should include('Another Application')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue