diff --git a/lib/webrat.rb b/lib/webrat.rb index 782cf2e..d983278 100644 --- a/lib/webrat.rb +++ b/lib/webrat.rb @@ -1,5 +1,7 @@ require "rubygems" +$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__))) + module Webrat VERSION = '0.2.2' @@ -8,10 +10,9 @@ module Webrat end end -require File.dirname(__FILE__) + "/webrat/core_extensions/blank" -require File.dirname(__FILE__) + "/webrat/core_extensions/hash_with_indifferent_access" -require File.dirname(__FILE__) + "/webrat/core_extensions/nil_to_param" -require File.dirname(__FILE__) + "/webrat/core" +# require "webrat/merb/param_parser" +# require "webrat/merb/url_encoded_pair_parser" +require "webrat/core" -require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV) -require File.dirname(__FILE__) + "/webrat/merb" if defined?(Merb) +require "webrat/rails" if defined?(RAILS_ENV) +require "webrat/merb" if defined?(Merb) diff --git a/lib/webrat/core.rb b/lib/webrat/core.rb index dda9e6e..b7aaf4f 100644 --- a/lib/webrat/core.rb +++ b/lib/webrat/core.rb @@ -1,3 +1,9 @@ -Dir[File.join(File.dirname(__FILE__), "core", "*.rb")].sort.each do |file| - require File.expand_path(file) -end \ No newline at end of file +require "webrat/core/logging" +require "webrat/core/flunk" +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" diff --git a/lib/webrat/core/field.rb b/lib/webrat/core/field.rb index f415073..31e244b 100644 --- a/lib/webrat/core/field.rb +++ b/lib/webrat/core/field.rb @@ -1,4 +1,7 @@ require "cgi" +require "webrat/core_extensions/blank" +require "webrat/core_extensions/nil_to_param" +require "webrat/merb/param_parser" module Webrat class Field diff --git a/lib/webrat/core/form.rb b/lib/webrat/core/form.rb index 4522710..e8eed28 100644 --- a/lib/webrat/core/form.rb +++ b/lib/webrat/core/form.rb @@ -1,3 +1,6 @@ +require "webrat/core/field" +require "webrat/core_extensions/blank" + module Webrat class Form attr_reader :element diff --git a/lib/webrat/core/link.rb b/lib/webrat/core/link.rb index 83e7bdc..a8cb90d 100644 --- a/lib/webrat/core/link.rb +++ b/lib/webrat/core/link.rb @@ -1,3 +1,5 @@ +require "webrat/core_extensions/blank" + module Webrat class Link diff --git a/lib/webrat/core/scope.rb b/lib/webrat/core/scope.rb index 113d5db..f09905a 100644 --- a/lib/webrat/core/scope.rb +++ b/lib/webrat/core/scope.rb @@ -1,4 +1,6 @@ require "hpricot" +require "webrat/core/form" +require "webrat/core/assertions" module Webrat class Scope diff --git a/lib/webrat/mechanize.rb b/lib/webrat/mechanize.rb index 5b8f1aa..bbab47b 100644 --- a/lib/webrat/mechanize.rb +++ b/lib/webrat/mechanize.rb @@ -1,5 +1,3 @@ -require "rubygems" require "mechanize" - -require File.dirname(__FILE__) + "/mechanize/mechanize_session" +require "webrat/mechanize/mechanize_session" diff --git a/lib/webrat/merb.rb b/lib/webrat/merb.rb index 9d1dc8d..0f2257e 100644 --- a/lib/webrat/merb.rb +++ b/lib/webrat/merb.rb @@ -1,6 +1,4 @@ -Dir[File.join(File.dirname(__FILE__), "merb", "*.rb")].sort.each do |file| - require File.expand_path(file) -end +require "webrat/core" module Webrat class Session @@ -32,7 +30,8 @@ module Webrat @response.status end - protected + protected + def do_request(url, data, headers, 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 diff --git a/lib/webrat/merb/param_parser.rb b/lib/webrat/merb/param_parser.rb index 0ee2e5f..d2b55c7 100644 --- a/lib/webrat/merb/param_parser.rb +++ b/lib/webrat/merb/param_parser.rb @@ -1,4 +1,6 @@ require "cgi" +require "webrat/core_extensions/blank" +require "webrat/merb/url_encoded_pair_parser" module Webrat class ParamParser diff --git a/lib/webrat/merb/url_encoded_pair_parser.rb b/lib/webrat/merb/url_encoded_pair_parser.rb index 63c74f0..1182395 100644 --- a/lib/webrat/merb/url_encoded_pair_parser.rb +++ b/lib/webrat/merb/url_encoded_pair_parser.rb @@ -1,5 +1,6 @@ require "cgi" require "strscan" +require "webrat/core_extensions/hash_with_indifferent_access" class UrlEncodedPairParser < StringScanner #:nodoc: attr_reader :top, :parent, :result diff --git a/lib/webrat/rails.rb b/lib/webrat/rails.rb index c3b685b..eb5e816 100644 --- a/lib/webrat/rails.rb +++ b/lib/webrat/rails.rb @@ -1,3 +1,4 @@ -require File.dirname(__FILE__) + "/rails/redirect_actions" -require File.dirname(__FILE__) + "/rails/rails_session" -require File.dirname(__FILE__) + "/rails/session" +require "webrat/core" +require "webrat/rails/redirect_actions" +require "webrat/rails/rails_session" +require "webrat/rails/session" \ No newline at end of file diff --git a/lib/webrat/selenium.rb b/lib/webrat/selenium.rb index e7ffafe..836513c 100644 --- a/lib/webrat/selenium.rb +++ b/lib/webrat/selenium.rb @@ -1,5 +1,3 @@ -require "rubygems" require "selenium" - -require File.dirname(__FILE__) + "/selenium/selenium_session" +require "webrat/selenium/selenium_session" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1d8feba..53e5896 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,11 @@ require "rubygems" require "spec" -require "spec/interop/test" # gem install redgreen for colored test output 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__) + "/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| # Nothing to configure yet diff --git a/spec/webrat/mechanize/mechanize_session_spec.rb b/spec/webrat/mechanize/mechanize_session_spec.rb index f69dad2..aa5077e 100644 --- a/spec/webrat/mechanize/mechanize_session_spec.rb +++ b/spec/webrat/mechanize/mechanize_session_spec.rb @@ -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 before(:each) do diff --git a/spec/webrat/rails/attaches_file_spec.rb b/spec/webrat/rails/attaches_file_spec.rb index 86a4124..0f5c97b 100644 --- a/spec/webrat/rails/attaches_file_spec.rb +++ b/spec/webrat/rails/attaches_file_spec.rb @@ -1,4 +1,3 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require File.expand_path(File.dirname(__FILE__) + '/helper') describe "attaches_file" do diff --git a/spec/webrat/rails/helper.rb b/spec/webrat/rails/helper.rb index 05d8068..5bf8af6 100644 --- a/spec/webrat/rails/helper.rb +++ b/spec/webrat/rails/helper.rb @@ -1,7 +1,9 @@ +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require "active_support" silence_warnings do require "action_controller" require "action_controller/integration" end -require File.expand_path(File.dirname(__FILE__) + "/../../../lib/webrat/rails") + +require "webrat/rails" diff --git a/spec/webrat/rails/rails_session_spec.rb b/spec/webrat/rails/rails_session_spec.rb index fad4692..a4eb95b 100644 --- a/spec/webrat/rails/rails_session_spec.rb +++ b/spec/webrat/rails/rails_session_spec.rb @@ -1,4 +1,3 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require File.expand_path(File.dirname(__FILE__) + '/helper') describe Webrat::RailsSession do