davidtrogers-webrat 0.4.4.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/Gemfile +19 -0
- data/History.txt +99 -9
- data/Rakefile +141 -207
- data/Thorfile +118 -0
- data/lib/webrat.rb +10 -23
- data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +6 -2
- data/lib/webrat/adapters/merb.rb +11 -0
- data/lib/webrat/adapters/rack.rb +25 -0
- data/lib/webrat/{rails.rb → adapters/rails.rb} +5 -37
- data/lib/webrat/adapters/sinatra.rb +9 -0
- data/lib/webrat/core.rb +0 -1
- data/lib/webrat/core/configuration.rb +22 -18
- data/lib/webrat/core/elements/area.rb +2 -2
- data/lib/webrat/core/elements/element.rb +3 -3
- data/lib/webrat/core/elements/field.rb +113 -31
- data/lib/webrat/core/elements/form.rb +4 -4
- data/lib/webrat/core/elements/label.rb +4 -4
- data/lib/webrat/core/elements/link.rb +8 -7
- data/lib/webrat/core/elements/select_option.rb +15 -2
- data/lib/webrat/core/locators.rb +1 -1
- data/lib/webrat/core/locators/area_locator.rb +3 -3
- data/lib/webrat/core/locators/button_locator.rb +6 -6
- data/lib/webrat/core/locators/field_by_id_locator.rb +3 -3
- data/lib/webrat/core/locators/field_labeled_locator.rb +2 -2
- data/lib/webrat/core/locators/field_named_locator.rb +3 -3
- data/lib/webrat/core/locators/form_locator.rb +1 -1
- data/lib/webrat/core/locators/label_locator.rb +2 -2
- data/lib/webrat/core/locators/link_locator.rb +16 -8
- data/lib/webrat/core/locators/select_option_locator.rb +5 -5
- data/lib/webrat/core/logging.rb +4 -5
- data/lib/webrat/core/matchers/have_content.rb +3 -8
- data/lib/webrat/core/matchers/have_xpath.rb +3 -28
- data/lib/webrat/core/methods.rb +5 -4
- data/lib/webrat/core/mime.rb +11 -22
- data/lib/webrat/core/save_and_open_page.rb +7 -29
- data/lib/webrat/core/scope.rb +17 -2
- data/lib/webrat/core/session.rb +31 -19
- data/lib/webrat/core/xml.rb +41 -84
- data/lib/webrat/integrations/merb.rb +10 -0
- data/lib/webrat/integrations/rails.rb +25 -0
- data/lib/webrat/integrations/rspec-rails.rb +11 -0
- data/lib/webrat/integrations/selenium.rb +11 -0
- data/lib/webrat/rspec-rails.rb +2 -13
- data/lib/webrat/selenium.rb +0 -11
- data/lib/webrat/selenium/application_server_factory.rb +40 -0
- data/lib/webrat/selenium/application_servers.rb +5 -0
- data/lib/webrat/selenium/application_servers/base.rb +46 -0
- data/lib/webrat/selenium/application_servers/external.rb +26 -0
- data/lib/webrat/selenium/application_servers/merb.rb +50 -0
- data/lib/webrat/selenium/application_servers/rails.rb +44 -0
- data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
- data/lib/webrat/selenium/location_strategy_javascript/label.js +30 -3
- data/lib/webrat/selenium/location_strategy_javascript/webrat.js +1 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +24 -4
- data/lib/webrat/selenium/matchers/have_content.rb +22 -10
- data/lib/webrat/selenium/matchers/have_selector.rb +8 -0
- data/lib/webrat/selenium/matchers/have_xpath.rb +8 -0
- data/lib/webrat/selenium/selenium_rc_server.rb +8 -6
- data/lib/webrat/selenium/selenium_session.rb +43 -14
- data/lib/webrat/selenium/silence_stream.rb +2 -2
- data/spec/fakes/{test_session.rb → test_adapter.rb} +4 -5
- data/spec/integration/mechanize/Rakefile +7 -0
- data/spec/integration/mechanize/config.ru +2 -0
- data/spec/integration/mechanize/sample_app.rb +20 -0
- data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
- data/spec/integration/mechanize/spec/spec_helper.rb +29 -0
- data/spec/integration/merb/app/controllers/testing.rb +9 -0
- data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
- data/spec/integration/merb/config/router.rb +1 -0
- data/spec/integration/merb/spec/spec_helper.rb +2 -0
- data/spec/integration/merb/spec/webrat_spec.rb +7 -0
- data/spec/integration/rack/app.rb +89 -0
- data/spec/integration/rack/test/helper.rb +21 -0
- data/spec/integration/rack/test/webrat_rack_test.rb +57 -51
- data/spec/integration/rails/app/controllers/{application.rb → application_controller.rb} +0 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +16 -9
- data/spec/integration/rails/app/views/buttons/show.html.erb +0 -2
- data/spec/integration/rails/app/views/links/show.html.erb +2 -1
- data/spec/integration/rails/app/views/webrat/buttons.html.erb +0 -2
- data/spec/integration/rails/app/views/webrat/within.html.erb +3 -0
- data/spec/integration/rails/config/environment.rb +1 -1
- data/spec/integration/rails/config/routes.rb +2 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +12 -26
- data/spec/integration/rails/test/integration/fill_in_test.rb +1 -1
- data/spec/integration/rails/test/integration/link_click_test.rb +8 -2
- data/spec/integration/rails/test/integration/webrat_test.rb +53 -5
- data/spec/integration/rails/test/test_helper.rb +7 -5
- data/spec/integration/sinatra/test/test_helper.rb +3 -2
- data/spec/private/core/configuration_spec.rb +8 -27
- data/spec/private/core/field_spec.rb +14 -16
- data/spec/private/core/link_spec.rb +1 -1
- data/spec/private/core/session_spec.rb +23 -26
- data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -12
- data/spec/private/nokogiri_spec.rb +2 -2
- data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +11 -42
- data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
- data/spec/public/basic_auth_spec.rb +13 -2
- data/spec/public/click_button_spec.rb +10 -12
- data/spec/public/click_link_spec.rb +21 -0
- data/spec/public/fill_in_spec.rb +15 -0
- data/spec/public/matchers/contain_spec.rb +12 -19
- data/spec/public/matchers/have_selector_spec.rb +6 -2
- data/spec/public/matchers/have_xpath_spec.rb +3 -3
- data/spec/public/save_and_open_spec.rb +15 -17
- data/spec/public/select_spec.rb +232 -26
- data/spec/public/selenium/application_server_factory_spec.rb +49 -0
- data/spec/public/selenium/application_servers/external_spec.rb +12 -0
- data/spec/public/selenium/selenium_session_spec.rb +37 -0
- data/spec/spec_helper.rb +5 -1
- data/vendor/selenium-server.jar +0 -0
- metadata +119 -69
- data/.dotest/0001 +0 -34
- data/.dotest/0002 +0 -34
- data/.dotest/binary +0 -1
- data/.dotest/final-commit +0 -1
- data/.dotest/head-name +0 -1
- data/.dotest/info +0 -5
- data/.dotest/keep +0 -1
- data/.dotest/last +0 -1
- data/.dotest/msg +0 -0
- data/.dotest/msg-clean +0 -0
- data/.dotest/next +0 -1
- data/.dotest/onto +0 -1
- data/.dotest/orig-head +0 -1
- data/.dotest/patch +0 -29
- data/.dotest/sign +0 -1
- data/.dotest/utf8 +0 -1
- data/.dotest/whitespace +0 -1
- data/VERSION +0 -1
- data/lib/webrat/core/xml/hpricot.rb +0 -19
- data/lib/webrat/core/xml/nokogiri.rb +0 -76
- data/lib/webrat/core/xml/rexml.rb +0 -24
- data/lib/webrat/merb_session.rb +0 -65
- data/lib/webrat/rack.rb +0 -24
- data/lib/webrat/rack_test.rb +0 -32
- data/lib/webrat/selenium/application_server.rb +0 -73
- data/lib/webrat/selenium/merb_application_server.rb +0 -48
- data/lib/webrat/selenium/rails_application_server.rb +0 -42
- data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
- data/lib/webrat/sinatra.rb +0 -44
- data/spec/integration/rack/rack_app.rb +0 -16
- data/spec/integration/rack/test/test_helper.rb +0 -20
- data/spec/private/core/logging_spec.rb +0 -10
- data/spec/private/merb/merb_session_spec.rb +0 -42
data/Thorfile
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
module GemHelpers
|
2
|
+
|
3
|
+
def generate_gemspec
|
4
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
|
5
|
+
require "webrat"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "davidtrogers-webrat"
|
9
|
+
s.version = Webrat::VERSION
|
10
|
+
s.author = "Bryan Helmkamp"
|
11
|
+
s.email = "bryan@brynary.com"
|
12
|
+
s.homepage = "http://github.com/brynary/webrat"
|
13
|
+
s.summary = "Ruby Acceptance Testing for Web applications"
|
14
|
+
s.description = <<-EOS.strip
|
15
|
+
Webrat lets you quickly write expressive and robust acceptance tests
|
16
|
+
for a Ruby web application. It supports simulating a browser inside
|
17
|
+
a Ruby process to avoid the performance hit and browser dependency of
|
18
|
+
Selenium or Watir, but the same API can also be used to drive real
|
19
|
+
Selenium tests when necessary (eg. for testing AJAX interactions).
|
20
|
+
Most Ruby web frameworks and testing frameworks are supported.
|
21
|
+
EOS
|
22
|
+
s.rubyforge_project = "webrat"
|
23
|
+
|
24
|
+
require "git"
|
25
|
+
repo = Git.open(".")
|
26
|
+
|
27
|
+
s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files)
|
28
|
+
s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files)
|
29
|
+
|
30
|
+
s.has_rdoc = true
|
31
|
+
s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
|
32
|
+
|
33
|
+
s.add_dependency "nokogiri", ">= 1.2.0"
|
34
|
+
s.add_dependency "rack", ">= 1.0"
|
35
|
+
s.add_dependency "rack-test", ">= 0.5.3"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def normalize_files(array)
|
40
|
+
# only keep files, no directories, and sort
|
41
|
+
array.select do |path|
|
42
|
+
File.file?(path)
|
43
|
+
end.sort
|
44
|
+
end
|
45
|
+
|
46
|
+
# Adds extra space when outputting an array. This helps create better version
|
47
|
+
# control diffs, because otherwise it is all on the same line.
|
48
|
+
def prettyify_array(gemspec_ruby, array_name)
|
49
|
+
gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
|
50
|
+
leadin, files = match[0..-2].split("[")
|
51
|
+
leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def read_gemspec
|
56
|
+
@read_gemspec ||= eval(File.read("davidtrogers-webrat.gemspec"))
|
57
|
+
end
|
58
|
+
|
59
|
+
def sh(command)
|
60
|
+
puts command
|
61
|
+
system command
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Default < Thor
|
66
|
+
include GemHelpers
|
67
|
+
|
68
|
+
desc "gemspec", "Regenerate davidtrogers-webrat.gemspec"
|
69
|
+
def gemspec
|
70
|
+
File.open("davidtrogers-webrat.gemspec", "w") do |file|
|
71
|
+
gemspec_ruby = generate_gemspec.to_ruby
|
72
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :files)
|
73
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
|
74
|
+
gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
|
75
|
+
|
76
|
+
file.write gemspec_ruby
|
77
|
+
end
|
78
|
+
|
79
|
+
puts "Wrote gemspec to davidtrogers-webrat.gemspec"
|
80
|
+
read_gemspec.validate
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "build", "Build a webrat gem"
|
84
|
+
def build
|
85
|
+
sh "gem build davidtrogers-webrat.gemspec"
|
86
|
+
FileUtils.mkdir_p "pkg"
|
87
|
+
FileUtils.mv read_gemspec.file_name, "pkg"
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "install", "Install the latest built gem"
|
91
|
+
def install
|
92
|
+
sh "gem install --local pkg/#{read_gemspec.file_name}"
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "release", "Release the current branch to GitHub and Gemcutter"
|
96
|
+
def release
|
97
|
+
gemspec
|
98
|
+
build
|
99
|
+
Release.new.tag
|
100
|
+
Release.new.gem
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class Release < Thor
|
105
|
+
include GemHelpers
|
106
|
+
|
107
|
+
desc "tag", "Tag the gem on the origin server"
|
108
|
+
def tag
|
109
|
+
release_tag = "v#{read_gemspec.version}"
|
110
|
+
sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
|
111
|
+
sh "git push origin #{release_tag}"
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "gem", "Push the gem to Gemcutter"
|
115
|
+
def gem
|
116
|
+
sh "gem push pkg/#{read_gemspec.file_name}"
|
117
|
+
end
|
118
|
+
end
|
data/lib/webrat.rb
CHANGED
@@ -1,31 +1,18 @@
|
|
1
|
-
require "
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
1
|
+
require "rack"
|
2
|
+
require "nokogiri"
|
4
3
|
|
5
4
|
module Webrat
|
6
|
-
|
7
|
-
class WebratError < StandardError
|
8
|
-
end
|
9
|
-
|
10
|
-
VERSION = '0.4.4'
|
5
|
+
VERSION = "0.7.1.pre"
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
7
|
+
autoload :MechanizeAdapter, "webrat/adapters/mechanize"
|
8
|
+
autoload :MerbAdapter, "webrat/adapters/merb"
|
9
|
+
autoload :RackAdapter, "webrat/adapters/rack"
|
10
|
+
autoload :RailsAdapter, "webrat/adapters/rails"
|
11
|
+
autoload :SinatraAdapter, "webrat/adapters/sinatra"
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.on_java?
|
24
|
-
RUBY_PLATFORM =~ /java/
|
13
|
+
# The common base class for all exceptions raised by Webrat.
|
14
|
+
class WebratError < StandardError
|
25
15
|
end
|
26
|
-
|
27
16
|
end
|
28
17
|
|
29
|
-
Webrat.require_xml
|
30
|
-
|
31
18
|
require "webrat/core"
|
@@ -1,11 +1,15 @@
|
|
1
1
|
require "mechanize"
|
2
2
|
|
3
3
|
module Webrat #:nodoc:
|
4
|
-
class
|
4
|
+
class MechanizeAdapter #:nodoc:
|
5
|
+
extend Forwardable
|
5
6
|
|
6
7
|
attr_accessor :response
|
7
8
|
alias :page :response
|
8
9
|
|
10
|
+
def initialize(*args)
|
11
|
+
end
|
12
|
+
|
9
13
|
def request_page(url, http_method, data) #:nodoc:
|
10
14
|
super(absolute_url(url), http_method, data)
|
11
15
|
end
|
@@ -67,7 +71,7 @@ module Webrat #:nodoc:
|
|
67
71
|
else
|
68
72
|
current_path.split("/")[0..(-1 - levels_up)].join("/")
|
69
73
|
end
|
70
|
-
descendent = url.split("/")[levels_up..-1]
|
74
|
+
descendent = url.split("/")[levels_up..-1].join
|
71
75
|
"#{ancestor}/#{descendent}"
|
72
76
|
end
|
73
77
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "webrat/integrations/merb"
|
2
|
+
|
3
|
+
module Webrat
|
4
|
+
class MerbAdapter < RackAdapter #:nodoc:
|
5
|
+
def initialize(context=nil)
|
6
|
+
app = context.respond_to?(:app) ?
|
7
|
+
context.app : Merb::Rack::Application.new
|
8
|
+
super(Rack::Test::Session.new(Rack::MockSession.new(app, "www.example.com")))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rack/test"
|
2
|
+
|
3
|
+
module Webrat
|
4
|
+
class RackAdapter
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :@session, :get, :post, :put, :delete
|
8
|
+
|
9
|
+
def initialize(session) #:nodoc:
|
10
|
+
@session = session
|
11
|
+
end
|
12
|
+
|
13
|
+
def response_body
|
14
|
+
response.body
|
15
|
+
end
|
16
|
+
|
17
|
+
def response_code
|
18
|
+
response.status
|
19
|
+
end
|
20
|
+
|
21
|
+
def response
|
22
|
+
@session.last_response
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,34 +1,14 @@
|
|
1
|
-
require "webrat"
|
2
|
-
|
3
|
-
require "action_controller"
|
4
|
-
require "action_controller/integration"
|
1
|
+
require "webrat/integrations/rails"
|
5
2
|
require "action_controller/record_identifier"
|
6
3
|
|
7
4
|
module Webrat
|
8
|
-
class
|
5
|
+
class RailsAdapter #:nodoc:
|
9
6
|
include ActionController::RecordIdentifier
|
10
7
|
|
11
|
-
|
12
|
-
# will apply a scope based on Rails' dom_id for that model.
|
13
|
-
#
|
14
|
-
# Example:
|
15
|
-
# within User.last do
|
16
|
-
# click_link "Delete"
|
17
|
-
# end
|
18
|
-
def within(selector_or_object, &block)
|
19
|
-
if selector_or_object.is_a?(String)
|
20
|
-
super
|
21
|
-
else
|
22
|
-
super('#' + dom_id(selector_or_object), &block)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def doc_root
|
27
|
-
File.expand_path(File.join(RAILS_ROOT, 'public'))
|
28
|
-
end
|
8
|
+
attr_reader :integration_session
|
29
9
|
|
30
|
-
def
|
31
|
-
|
10
|
+
def initialize(session)
|
11
|
+
@integration_session = session
|
32
12
|
end
|
33
13
|
|
34
14
|
def get(url, data, headers = nil)
|
@@ -61,10 +41,6 @@ module Webrat
|
|
61
41
|
|
62
42
|
protected
|
63
43
|
|
64
|
-
def integration_session
|
65
|
-
@context
|
66
|
-
end
|
67
|
-
|
68
44
|
def do_request(http_method, url, data, headers) #:nodoc:
|
69
45
|
update_protocol(url)
|
70
46
|
integration_session.send(http_method, normalize_url(url), data, headers)
|
@@ -93,13 +69,5 @@ module Webrat
|
|
93
69
|
def response #:nodoc:
|
94
70
|
integration_session.response
|
95
71
|
end
|
96
|
-
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
module ActionController #:nodoc:
|
101
|
-
IntegrationTest.class_eval do
|
102
|
-
include Webrat::Methods
|
103
|
-
include Webrat::Matchers
|
104
72
|
end
|
105
73
|
end
|
data/lib/webrat/core.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "webrat/core_extensions/deprecate"
|
2
|
+
require "pathname"
|
2
3
|
|
3
4
|
module Webrat
|
4
5
|
|
@@ -16,20 +17,20 @@ module Webrat
|
|
16
17
|
# Webrat can be configured using the Webrat.configure method. For example:
|
17
18
|
#
|
18
19
|
# Webrat.configure do |config|
|
19
|
-
# config.
|
20
|
+
# config.mode = :sinatra
|
20
21
|
# end
|
21
22
|
class Configuration
|
22
23
|
|
23
|
-
# Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used
|
24
|
-
attr_writer :parse_with_nokogiri
|
25
|
-
|
26
24
|
# Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc.
|
27
25
|
attr_reader :mode # :nodoc:
|
28
26
|
|
29
27
|
# Save and open pages with error status codes (500-599) in a browser? Defualts to true.
|
30
28
|
attr_writer :open_error_files
|
31
29
|
|
32
|
-
#
|
30
|
+
# Save and open page storage directory, defaults to "tmp" under current directory if exists, otherwise current directory
|
31
|
+
attr_accessor :saved_pages_dir
|
32
|
+
|
33
|
+
# Which rails environment should the selenium tests be run in? Defaults to test.
|
33
34
|
attr_accessor :application_environment
|
34
35
|
webrat_deprecate :selenium_environment, :application_environment
|
35
36
|
webrat_deprecate :selenium_environment=, :application_environment=
|
@@ -39,6 +40,13 @@ module Webrat
|
|
39
40
|
webrat_deprecate :selenium_port, :application_port
|
40
41
|
webrat_deprecate :selenium_port=, :application_port=
|
41
42
|
|
43
|
+
# Which port should selenium use to access the application. Defaults to application_port
|
44
|
+
attr_writer :application_port_for_selenium
|
45
|
+
|
46
|
+
def application_port_for_selenium
|
47
|
+
@application_port_for_selenium || self.application_port
|
48
|
+
end
|
49
|
+
|
42
50
|
# Which underlying app framework we're testing with selenium
|
43
51
|
attr_accessor :application_framework
|
44
52
|
|
@@ -53,7 +61,7 @@ module Webrat
|
|
53
61
|
|
54
62
|
# Set the key that Selenium uses to determine the browser running. Default *firefox
|
55
63
|
attr_accessor :selenium_browser_key
|
56
|
-
|
64
|
+
|
57
65
|
# Set the timeout for waiting for the browser process to start
|
58
66
|
attr_accessor :selenium_browser_startup_timeout
|
59
67
|
|
@@ -63,7 +71,6 @@ module Webrat
|
|
63
71
|
|
64
72
|
def initialize # :nodoc:
|
65
73
|
self.open_error_files = true
|
66
|
-
self.parse_with_nokogiri = true
|
67
74
|
self.application_environment = :test
|
68
75
|
self.application_port = 3001
|
69
76
|
self.application_address = 'localhost'
|
@@ -72,12 +79,11 @@ module Webrat
|
|
72
79
|
self.infinite_redirect_limit = 10
|
73
80
|
self.selenium_browser_key = '*firefox'
|
74
81
|
self.selenium_browser_startup_timeout = 5
|
75
|
-
end
|
76
82
|
|
77
|
-
|
78
|
-
|
83
|
+
tmp_dir = Pathname.new(Dir.pwd).join("tmp")
|
84
|
+
self.saved_pages_dir = tmp_dir.exist? ? tmp_dir : Dir.pwd
|
79
85
|
end
|
80
|
-
|
86
|
+
|
81
87
|
def open_error_files? #:nodoc:
|
82
88
|
@open_error_files ? true : false
|
83
89
|
end
|
@@ -87,13 +93,11 @@ module Webrat
|
|
87
93
|
def mode=(mode)
|
88
94
|
@mode = mode.to_sym
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
else
|
96
|
-
require("webrat/#{mode}")
|
96
|
+
begin
|
97
|
+
require("webrat/integrations/#{mode}")
|
98
|
+
rescue LoadError
|
99
|
+
# Only some modes have integration code that needs to
|
100
|
+
# be loaded, so this is OK
|
97
101
|
end
|
98
102
|
end
|
99
103
|
|
@@ -4,7 +4,7 @@ module Webrat
|
|
4
4
|
class Area < Element #:nodoc:
|
5
5
|
|
6
6
|
def self.xpath_search
|
7
|
-
".//area"
|
7
|
+
[".//area"]
|
8
8
|
end
|
9
9
|
|
10
10
|
def click(method = nil, options = {})
|
@@ -14,7 +14,7 @@ module Webrat
|
|
14
14
|
protected
|
15
15
|
|
16
16
|
def href
|
17
|
-
|
17
|
+
@element["href"]
|
18
18
|
end
|
19
19
|
|
20
20
|
def absolute_href
|
@@ -3,14 +3,14 @@ module Webrat
|
|
3
3
|
class Element # :nodoc:
|
4
4
|
|
5
5
|
def self.load_all(session, dom)
|
6
|
-
|
6
|
+
dom.xpath(*xpath_search).map do |element|
|
7
7
|
load(session, element)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(session, element)
|
12
12
|
return nil if element.nil?
|
13
|
-
session.elements[
|
13
|
+
session.elements[element.path] ||= self.new(session, element)
|
14
14
|
end
|
15
15
|
|
16
16
|
attr_reader :element
|
@@ -21,7 +21,7 @@ module Webrat
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def path
|
24
|
-
|
24
|
+
@element.path
|
25
25
|
end
|
26
26
|
|
27
27
|
def inspect
|