From eef4e74a9f5127b1b87807b21209cb9e3f6e6bfd Mon Sep 17 00:00:00 2001 From: Jonas Nicklas Date: Thu, 12 Nov 2009 18:57:46 +0100 Subject: [PATCH] DSL only has a single app Just makes more sense --- lib/webcat/dsl.rb | 16 +++++++++------- spec/dsl_spec.rb | 4 ---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/webcat/dsl.rb b/lib/webcat/dsl.rb index 94e6a681..c4d5b8fa 100644 --- a/lib/webcat/dsl.rb +++ b/lib/webcat/dsl.rb @@ -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 diff --git a/spec/dsl_spec.rb b/spec/dsl_spec.rb index 4e54768a..93492635 100644 --- a/spec/dsl_spec.rb +++ b/spec/dsl_spec.rb @@ -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