Cleaning up require structure

This commit is contained in:
Bryan Helmkamp 2008-10-25 12:59:21 -04:00
parent 324f412c7e
commit 2473cccb92
17 changed files with 44 additions and 29 deletions

View File

@ -1,5 +1,7 @@
require "rubygems" require "rubygems"
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
module Webrat module Webrat
VERSION = '0.2.2' VERSION = '0.2.2'
@ -8,10 +10,9 @@ module Webrat
end end
end end
require File.dirname(__FILE__) + "/webrat/core_extensions/blank" # require "webrat/merb/param_parser"
require File.dirname(__FILE__) + "/webrat/core_extensions/hash_with_indifferent_access" # require "webrat/merb/url_encoded_pair_parser"
require File.dirname(__FILE__) + "/webrat/core_extensions/nil_to_param" require "webrat/core"
require File.dirname(__FILE__) + "/webrat/core"
require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV) require "webrat/rails" if defined?(RAILS_ENV)
require File.dirname(__FILE__) + "/webrat/merb" if defined?(Merb) require "webrat/merb" if defined?(Merb)

View File

@ -1,3 +1,9 @@
Dir[File.join(File.dirname(__FILE__), "core", "*.rb")].sort.each do |file| require "webrat/core/logging"
require File.expand_path(file) require "webrat/core/flunk"
end require "webrat/core/form"
require "webrat/core/scope"
require "webrat/core/link"
require "webrat/core/area"
require "webrat/core/label"
require "webrat/core/select_option"
require "webrat/core/session"

View File

@ -1,4 +1,7 @@
require "cgi" require "cgi"
require "webrat/core_extensions/blank"
require "webrat/core_extensions/nil_to_param"
require "webrat/merb/param_parser"
module Webrat module Webrat
class Field class Field

View File

@ -1,3 +1,6 @@
require "webrat/core/field"
require "webrat/core_extensions/blank"
module Webrat module Webrat
class Form class Form
attr_reader :element attr_reader :element

View File

@ -1,3 +1,5 @@
require "webrat/core_extensions/blank"
module Webrat module Webrat
class Link class Link

View File

@ -1,4 +1,6 @@
require "hpricot" require "hpricot"
require "webrat/core/form"
require "webrat/core/assertions"
module Webrat module Webrat
class Scope class Scope

View File

@ -1,5 +1,3 @@
require "rubygems"
require "mechanize" require "mechanize"
require "webrat/mechanize/mechanize_session"
require File.dirname(__FILE__) + "/mechanize/mechanize_session"

View File

@ -1,6 +1,4 @@
Dir[File.join(File.dirname(__FILE__), "merb", "*.rb")].sort.each do |file| require "webrat/core"
require File.expand_path(file)
end
module Webrat module Webrat
class Session class Session
@ -33,6 +31,7 @@ module Webrat
end end
protected protected
def do_request(url, data, headers, method) def do_request(url, data, headers, method)
@response = request(url, :params => (data && data.any?) ? data : nil, :headers => headers, :method => method) @response = request(url, :params => (data && data.any?) ? data : nil, :headers => headers, :method => method)
self.get(@response.headers['Location'], nil, @response.headers) if @response.status == 302 self.get(@response.headers['Location'], nil, @response.headers) if @response.status == 302

View File

@ -1,4 +1,6 @@
require "cgi" require "cgi"
require "webrat/core_extensions/blank"
require "webrat/merb/url_encoded_pair_parser"
module Webrat module Webrat
class ParamParser class ParamParser

View File

@ -1,5 +1,6 @@
require "cgi" require "cgi"
require "strscan" require "strscan"
require "webrat/core_extensions/hash_with_indifferent_access"
class UrlEncodedPairParser < StringScanner #:nodoc: class UrlEncodedPairParser < StringScanner #:nodoc:
attr_reader :top, :parent, :result attr_reader :top, :parent, :result

View File

@ -1,3 +1,4 @@
require File.dirname(__FILE__) + "/rails/redirect_actions" require "webrat/core"
require File.dirname(__FILE__) + "/rails/rails_session" require "webrat/rails/redirect_actions"
require File.dirname(__FILE__) + "/rails/session" require "webrat/rails/rails_session"
require "webrat/rails/session"

View File

@ -1,5 +1,3 @@
require "rubygems"
require "selenium" require "selenium"
require "webrat/selenium/selenium_session"
require File.dirname(__FILE__) + "/selenium/selenium_session"

View File

@ -1,14 +1,11 @@
require "rubygems" require "rubygems"
require "spec" require "spec"
require "spec/interop/test"
# gem install redgreen for colored test output # gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat") require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat")
require File.expand_path(File.dirname(__FILE__) + "/fakes/test_session") require File.expand_path(File.dirname(__FILE__) + "/fakes/test_session")
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat/merb/param_parser")
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat/merb/url_encoded_pair_parser")
Spec::Runner.configure do |config| Spec::Runner.configure do |config|
# Nothing to configure yet # Nothing to configure yet

View File

@ -1,4 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../../../lib/webrat/mechanize") require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require "mechanize"
require "webrat/mechanize"
describe Webrat::MechanizeSession do describe Webrat::MechanizeSession do
before(:each) do before(:each) do

View File

@ -1,4 +1,3 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/helper') require File.expand_path(File.dirname(__FILE__) + '/helper')
describe "attaches_file" do describe "attaches_file" do

View File

@ -1,7 +1,9 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require "active_support" require "active_support"
silence_warnings do silence_warnings do
require "action_controller" require "action_controller"
require "action_controller/integration" require "action_controller/integration"
end end
require File.expand_path(File.dirname(__FILE__) + "/../../../lib/webrat/rails")
require "webrat/rails"

View File

@ -1,4 +1,3 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require File.expand_path(File.dirname(__FILE__) + '/helper') require File.expand_path(File.dirname(__FILE__) + '/helper')
describe Webrat::RailsSession do describe Webrat::RailsSession do