honkster-webrat 0.4.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +4 -0
- data/.gitignore +16 -0
- data/History.txt +56 -1
- data/Rakefile +79 -91
- data/VERSION +1 -0
- data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +5 -1
- data/lib/webrat/adapters/merb.rb +11 -0
- data/lib/webrat/adapters/rack.rb +25 -0
- data/lib/webrat/{rails.rb → adapters/rails.rb} +6 -30
- data/lib/webrat/adapters/sinatra.rb +9 -0
- data/lib/webrat/core/configuration.rb +6 -16
- 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 +107 -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 +5 -5
- data/lib/webrat/core/elements/select_option.rb +15 -2
- 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 +7 -7
- data/lib/webrat/core/locators/select_option_locator.rb +5 -5
- data/lib/webrat/core/locators.rb +1 -1
- data/lib/webrat/core/logging.rb +4 -5
- data/lib/webrat/core/matchers/have_content.rb +2 -7
- 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/scope.rb +17 -2
- data/lib/webrat/core/session.rb +28 -12
- data/lib/webrat/core/xml.rb +41 -84
- data/lib/webrat/core.rb +0 -1
- data/lib/webrat/integrations/merb.rb +10 -0
- data/lib/webrat/integrations/rails.rb +25 -0
- data/lib/webrat/integrations/rspec-rails.rb +10 -0
- data/lib/webrat/integrations/selenium.rb +11 -0
- data/lib/webrat/rspec-rails.rb +2 -10
- data/lib/webrat/selenium/application_servers/external.rb +1 -1
- data/lib/webrat/selenium/application_servers.rb +1 -1
- data/lib/webrat/selenium/location_strategy_javascript/label.js +31 -13
- 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/selenium_rc_server.rb +4 -2
- data/lib/webrat/selenium/selenium_session.rb +21 -2
- data/lib/webrat/selenium/silence_stream.rb +1 -1
- data/lib/webrat/selenium.rb +0 -11
- data/lib/webrat.rb +10 -19
- data/spec/fakes/test_adapter.rb +37 -0
- 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 +27 -0
- data/spec/integration/merb/.gitignore +21 -0
- data/spec/integration/merb/Rakefile +35 -0
- data/spec/integration/merb/app/controllers/application.rb +2 -0
- data/spec/integration/merb/app/controllers/exceptions.rb +13 -0
- data/spec/integration/merb/app/controllers/testing.rb +27 -0
- data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
- data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
- data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
- data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
- data/spec/integration/merb/config/environments/development.rb +15 -0
- data/spec/integration/merb/config/environments/rake.rb +11 -0
- data/spec/integration/merb/config/environments/test.rb +14 -0
- data/spec/integration/merb/config/init.rb +25 -0
- data/spec/integration/merb/config/rack.rb +11 -0
- data/spec/integration/merb/config/router.rb +34 -0
- data/spec/integration/merb/spec/spec.opts +1 -0
- data/spec/integration/merb/spec/spec_helper.rb +26 -0
- data/spec/integration/merb/spec/webrat_spec.rb +39 -0
- data/spec/integration/merb/tasks/merb.thor/app_script.rb +31 -0
- data/spec/integration/merb/tasks/merb.thor/common.rb +64 -0
- data/spec/integration/merb/tasks/merb.thor/gem_ext.rb +124 -0
- data/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
- data/spec/integration/merb/tasks/merb.thor/ops.rb +93 -0
- data/spec/integration/merb/tasks/merb.thor/utils.rb +40 -0
- data/spec/integration/rack/Rakefile +5 -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 +73 -0
- data/spec/integration/rails/.gitignore +3 -0
- data/spec/integration/rails/Rakefile +30 -0
- data/spec/integration/rails/app/controllers/application.rb +15 -0
- data/spec/integration/rails/app/controllers/buttons_controller.rb +7 -0
- data/spec/integration/rails/app/controllers/fields_controller.rb +4 -0
- data/spec/integration/rails/app/controllers/links_controller.rb +7 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +46 -0
- data/spec/integration/rails/app/helpers/buttons_helper.rb +2 -0
- data/spec/integration/rails/app/helpers/fields_helper.rb +2 -0
- data/spec/integration/rails/app/helpers/links_helper.rb +2 -0
- data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
- data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
- data/spec/integration/rails/app/views/links/show.html.erb +5 -0
- data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
- data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
- data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
- data/spec/integration/rails/app/views/webrat/within.html.erb +3 -0
- data/spec/integration/rails/config/boot.rb +109 -0
- data/spec/integration/rails/config/environment.rb +12 -0
- data/spec/integration/rails/config/environments/development.rb +17 -0
- data/spec/integration/rails/config/environments/selenium.rb +22 -0
- data/spec/integration/rails/config/environments/test.rb +22 -0
- data/spec/integration/rails/config/initializers/inflections.rb +10 -0
- data/spec/integration/rails/config/initializers/mime_types.rb +5 -0
- data/spec/integration/rails/config/initializers/new_rails_defaults.rb +17 -0
- data/spec/integration/rails/config/locales/en.yml +5 -0
- data/spec/integration/rails/config/routes.rb +19 -0
- data/spec/integration/rails/public/404.html +30 -0
- data/spec/integration/rails/public/422.html +30 -0
- data/spec/integration/rails/public/500.html +33 -0
- data/spec/integration/rails/script/about +4 -0
- data/spec/integration/rails/script/console +3 -0
- data/spec/integration/rails/script/dbconsole +3 -0
- data/spec/integration/rails/script/destroy +3 -0
- data/spec/integration/rails/script/generate +3 -0
- data/spec/integration/rails/script/performance/benchmarker +3 -0
- data/spec/integration/rails/script/performance/profiler +3 -0
- data/spec/integration/rails/script/performance/request +3 -0
- data/spec/integration/rails/script/plugin +3 -0
- data/spec/integration/rails/script/process/inspector +3 -0
- data/spec/integration/rails/script/process/reaper +3 -0
- data/spec/integration/rails/script/process/spawner +3 -0
- data/spec/integration/rails/script/runner +3 -0
- data/spec/integration/rails/script/server +3 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +80 -0
- data/spec/integration/rails/test/integration/fill_in_test.rb +24 -0
- data/spec/integration/rails/test/integration/link_click_test.rb +27 -0
- data/spec/integration/rails/test/integration/webrat_test.rb +122 -0
- data/spec/integration/rails/test/test_helper.rb +26 -0
- data/spec/integration/sinatra/Rakefile +5 -0
- data/spec/integration/sinatra/classic_app.rb +64 -0
- data/spec/integration/sinatra/modular_app.rb +16 -0
- data/spec/integration/sinatra/test/classic_app_test.rb +37 -0
- data/spec/integration/sinatra/test/modular_app_test.rb +18 -0
- data/spec/integration/sinatra/test/test_helper.rb +17 -0
- data/spec/private/core/configuration_spec.rb +87 -0
- data/spec/private/core/field_spec.rb +85 -0
- data/spec/private/core/link_spec.rb +24 -0
- data/spec/private/core/session_spec.rb +200 -0
- data/spec/private/mechanize/mechanize_adapter_spec.rb +73 -0
- data/spec/private/nokogiri_spec.rb +77 -0
- data/spec/private/rails/attaches_file_spec.rb +81 -0
- data/spec/private/rails/rails_adapter_spec.rb +86 -0
- data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
- data/spec/public/basic_auth_spec.rb +24 -0
- data/spec/public/check_spec.rb +191 -0
- data/spec/public/choose_spec.rb +118 -0
- data/spec/public/click_area_spec.rb +106 -0
- data/spec/public/click_button_spec.rb +494 -0
- data/spec/public/click_link_spec.rb +511 -0
- data/spec/public/fill_in_spec.rb +224 -0
- data/spec/public/locators/field_by_xpath_spec.rb +19 -0
- data/spec/public/locators/field_labeled_spec.rb +172 -0
- data/spec/public/locators/field_with_id_spec.rb +16 -0
- data/spec/public/matchers/contain_spec.rb +114 -0
- data/spec/public/matchers/have_selector_spec.rb +146 -0
- data/spec/public/matchers/have_tag_spec.rb +39 -0
- data/spec/public/matchers/have_xpath_spec.rb +136 -0
- data/spec/public/reload_spec.rb +10 -0
- data/spec/public/save_and_open_spec.rb +70 -0
- data/spec/public/select_date_spec.rb +112 -0
- data/spec/public/select_datetime_spec.rb +137 -0
- data/spec/public/select_spec.rb +455 -0
- data/spec/public/select_time_spec.rb +100 -0
- 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/public/set_hidden_field_spec.rb +5 -0
- data/spec/public/submit_form_spec.rb +5 -0
- data/spec/public/visit_spec.rb +58 -0
- data/spec/public/within_spec.rb +177 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +54 -0
- data/vendor/selenium-server.jar +0 -0
- data/webrat.gemspec +360 -0
- metadata +292 -27
- 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_multipart_support.rb +0 -27
- data/lib/webrat/merb_session.rb +0 -80
- data/lib/webrat/rack.rb +0 -24
- data/lib/webrat/rack_test.rb +0 -32
- data/lib/webrat/sinatra.rb +0 -44
data/.document
ADDED
data/.gitignore
ADDED
data/History.txt
CHANGED
|
@@ -1,4 +1,57 @@
|
|
|
1
|
-
== 0.
|
|
1
|
+
== 0.6.rc1 / 2009-09-22
|
|
2
|
+
|
|
3
|
+
REMOVED: Support for Hpricot + REXML as an alternative to Nokogiri.
|
|
4
|
+
|
|
5
|
+
Hpricot and REXML were difficult to work with, REXML is terribly slow,
|
|
6
|
+
and Nokogiri is recommended even by the author of Hpricot (_why). Now
|
|
7
|
+
that Nokogiri works on JRuby, Webrat is going to use it as its sole
|
|
8
|
+
XML backend.
|
|
9
|
+
|
|
10
|
+
CHANGED: Due to a reorganization, if you're currently requiring "webrat/rspec-rails",
|
|
11
|
+
please change your code to require "webrat/integrations/rspec-rails"
|
|
12
|
+
|
|
13
|
+
* Minor enhancements
|
|
14
|
+
|
|
15
|
+
* When a timeout occurs in wait_for, include the HTML from Selenium in the exception
|
|
16
|
+
* Update the Merb support to be based directly on Rack (Simon Rozet)
|
|
17
|
+
* Support multiple select fields (Kieran P)
|
|
18
|
+
* When locating select options, always match against text, not HTML
|
|
19
|
+
|
|
20
|
+
* Bug fixes
|
|
21
|
+
|
|
22
|
+
* Fix logger issue when running inside Cucumber (Damian Janowski)
|
|
23
|
+
* Fix various issues related to submitting values with HTML entities (Kieran P)
|
|
24
|
+
* Call #to_i on the :count option in matchers (Michael Christenson II)
|
|
25
|
+
* Fix bug where multiline param values were getting truncated
|
|
26
|
+
|
|
27
|
+
== 0.5.3 / 2009-08-27
|
|
28
|
+
|
|
29
|
+
* Minor enhancements
|
|
30
|
+
|
|
31
|
+
* Remove unnecessary requires which are to the wrong paths on Edge Rails
|
|
32
|
+
|
|
33
|
+
== 0.5.1 / 2009-08-18
|
|
34
|
+
|
|
35
|
+
* Minor enhancements
|
|
36
|
+
|
|
37
|
+
* Base Webrat::MIME on Rack::Mime (Simon Rozet)
|
|
38
|
+
* Support file uploads in Rack mode (Simon Rozet)
|
|
39
|
+
|
|
40
|
+
* Bug fixes
|
|
41
|
+
|
|
42
|
+
* Fix bug in Webrat::Methods preventing Selenium mode from working [#277]
|
|
43
|
+
|
|
44
|
+
== 0.5.0 / 2009-08-12
|
|
45
|
+
|
|
46
|
+
* Major enhancements
|
|
47
|
+
|
|
48
|
+
* Depreacate :rack_test and :sinatra in favor of :rack, which uses Rack::Test (Simon Rozet)
|
|
49
|
+
|
|
50
|
+
* Minor enhancements
|
|
51
|
+
|
|
52
|
+
* Don't require rubygems at runtime (Simon Rozet)
|
|
53
|
+
|
|
54
|
+
== 0.4.5 / 2009-08-10
|
|
2
55
|
|
|
3
56
|
* Major enhancements
|
|
4
57
|
|
|
@@ -9,6 +62,8 @@
|
|
|
9
62
|
|
|
10
63
|
* Minor enhancements
|
|
11
64
|
|
|
65
|
+
* Upgrade to selenium-client to 1.2.16 (Brian Landau)
|
|
66
|
+
* Upgrade selenium-server.jar to 1.0.1 (Brian Landau)
|
|
12
67
|
* Make redirect detection work in the face of rational maths (like when ruby-units is active) (Piers Cawley)
|
|
13
68
|
* Use Launchy to handle opening pages in the browser with cross-platform compatibility (Bryan Helmkamp)
|
|
14
69
|
* Added support for field_labeled_locators ending in non word characters
|
data/Rakefile
CHANGED
|
@@ -1,89 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Rake::GemPackageTask.new(spec) do |package|
|
|
38
|
-
package.gem_spec = spec
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
desc 'Show information about the gem.'
|
|
42
|
-
task :debug_gem do
|
|
43
|
-
puts spec.to_ruby
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
|
|
47
|
-
|
|
48
|
-
desc "Upload rdoc to brynary.com"
|
|
49
|
-
task :publish_rdoc => :docs do
|
|
50
|
-
sh "scp -r doc/ brynary.com:/apps/uploads/webrat"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
desc "Run API and Core specs"
|
|
54
|
-
Spec::Rake::SpecTask.new do |t|
|
|
55
|
-
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
56
|
-
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
desc "Run all specs in spec directory with RCov"
|
|
60
|
-
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
61
|
-
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
62
|
-
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
|
63
|
-
t.rcov = true
|
|
64
|
-
t.rcov_opts = lambda do
|
|
65
|
-
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
|
1
|
+
require "rubygems"
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'jeweler'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
desc "Install gem using sudo"
|
|
7
|
+
task(:install) do
|
|
8
|
+
$stderr.puts "Jeweler not available. `gem install jeweler` to install this gem"
|
|
9
|
+
end
|
|
10
|
+
else
|
|
11
|
+
Jeweler::Tasks.new do |s|
|
|
12
|
+
s.name = "honkster-webrat"
|
|
13
|
+
s.author = "Bryan Helmkamp"
|
|
14
|
+
s.email = "bryan" + "@" + "brynary.com"
|
|
15
|
+
s.homepage = "http://github.com/brynary/webrat"
|
|
16
|
+
s.summary = "Ruby Acceptance Testing for Web applications"
|
|
17
|
+
s.description = <<-EOS.strip
|
|
18
|
+
Webrat lets you quickly write expressive and robust acceptance tests
|
|
19
|
+
for a Ruby web application. It supports simulating a browser inside
|
|
20
|
+
a Ruby process to avoid the performance hit and browser dependency of
|
|
21
|
+
Selenium or Watir, but the same API can also be used to drive real
|
|
22
|
+
Selenium tests when necessary (eg. for testing AJAX interactions).
|
|
23
|
+
Most Ruby web frameworks and testing frameworks are supported.
|
|
24
|
+
EOS
|
|
25
|
+
|
|
26
|
+
s.rubyforge_project = "honkster-webrat"
|
|
27
|
+
s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
|
|
28
|
+
|
|
29
|
+
# Dependencies
|
|
30
|
+
s.add_dependency "nokogiri", ">= 1.2.0"
|
|
31
|
+
s.add_dependency "rack", ">= 1.0"
|
|
32
|
+
|
|
33
|
+
s.add_development_dependency "rails", ">= 2.3"
|
|
34
|
+
s.add_development_dependency "merb-core", ">= 1.0"
|
|
35
|
+
s.add_development_dependency "launchy"
|
|
66
36
|
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
|
70
|
-
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
|
|
71
|
-
end
|
|
72
37
|
|
|
73
|
-
|
|
74
|
-
task :install_gem => [:clean, :package] do
|
|
75
|
-
gem_filename = Dir['pkg/*.gem'].first
|
|
76
|
-
sh "sudo gem install --no-rdoc --no-ri --local #{gem_filename}"
|
|
38
|
+
Jeweler::RubyforgeTasks.new
|
|
77
39
|
end
|
|
78
40
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
41
|
+
begin
|
|
42
|
+
require 'spec/rake/spectask'
|
|
43
|
+
rescue LoadError
|
|
44
|
+
desc "Run specs"
|
|
45
|
+
task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
|
|
46
|
+
else
|
|
47
|
+
desc "Run API and Core specs"
|
|
48
|
+
Spec::Rake::SpecTask.new do |t|
|
|
49
|
+
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
50
|
+
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
|
51
|
+
end
|
|
83
52
|
|
|
84
|
-
desc "
|
|
85
|
-
|
|
86
|
-
|
|
53
|
+
desc "Run all specs in spec directory with RCov"
|
|
54
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
55
|
+
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
|
56
|
+
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
|
57
|
+
t.rcov = true
|
|
58
|
+
t.rcov_opts = lambda do
|
|
59
|
+
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
|
60
|
+
end
|
|
61
|
+
end
|
|
87
62
|
end
|
|
88
63
|
|
|
89
64
|
desc "Run everything against multiruby"
|
|
@@ -138,18 +113,18 @@ task :spec_deps do
|
|
|
138
113
|
end
|
|
139
114
|
end
|
|
140
115
|
|
|
141
|
-
task :prepare do
|
|
142
|
-
system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat"
|
|
143
|
-
end
|
|
144
|
-
|
|
145
116
|
namespace :spec do
|
|
146
117
|
desc "Run the integration specs"
|
|
147
|
-
task :integration => [
|
|
118
|
+
task :integration => [
|
|
119
|
+
"integration:rack",
|
|
120
|
+
"integration:sinatra",
|
|
121
|
+
"integration:merb",
|
|
122
|
+
"integration:mechanize",
|
|
123
|
+
"integration:rails:webrat",
|
|
124
|
+
"integration:rails:selenium",
|
|
125
|
+
]
|
|
148
126
|
|
|
149
127
|
namespace :integration do
|
|
150
|
-
desc "Run the Rails integration specs"
|
|
151
|
-
task :rails => ['rails:webrat'] #,'rails:selenium'] currently not running selenium as it doesn't pass.
|
|
152
|
-
|
|
153
128
|
namespace :rails do
|
|
154
129
|
task :selenium do
|
|
155
130
|
Dir.chdir "spec/integration/rails" do
|
|
@@ -189,12 +164,25 @@ namespace :spec do
|
|
|
189
164
|
raise "Rack integration tests failed" unless result
|
|
190
165
|
end
|
|
191
166
|
end
|
|
167
|
+
|
|
168
|
+
desc "Run the Mechanize integration specs"
|
|
169
|
+
task :mechanize do
|
|
170
|
+
Dir.chdir "spec/integration/mechanize" do
|
|
171
|
+
result = system "rake spec"
|
|
172
|
+
raise "Mechanize integration tests failed" unless result
|
|
173
|
+
end
|
|
174
|
+
end
|
|
192
175
|
end
|
|
193
176
|
end
|
|
194
177
|
|
|
195
|
-
task :default => :spec
|
|
196
|
-
|
|
197
178
|
desc 'Removes trailing whitespace'
|
|
198
179
|
task :whitespace do
|
|
199
180
|
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
|
200
181
|
end
|
|
182
|
+
|
|
183
|
+
if defined?(Jeweler)
|
|
184
|
+
task :spec => :check_dependencies
|
|
185
|
+
task :build => :gemspec
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
task :default => :spec
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.6.0
|
|
@@ -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
|
|
@@ -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,26 +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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
8
|
+
attr_reader :integration_session
|
|
9
|
+
|
|
10
|
+
def initialize(session)
|
|
11
|
+
@integration_session = session
|
|
24
12
|
end
|
|
25
13
|
|
|
26
14
|
def doc_root
|
|
@@ -61,10 +49,6 @@ module Webrat
|
|
|
61
49
|
|
|
62
50
|
protected
|
|
63
51
|
|
|
64
|
-
def integration_session
|
|
65
|
-
@context
|
|
66
|
-
end
|
|
67
|
-
|
|
68
52
|
def do_request(http_method, url, data, headers) #:nodoc:
|
|
69
53
|
update_protocol(url)
|
|
70
54
|
integration_session.send(http_method, normalize_url(url), data, headers)
|
|
@@ -93,13 +77,5 @@ module Webrat
|
|
|
93
77
|
def response #:nodoc:
|
|
94
78
|
integration_session.response
|
|
95
79
|
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
80
|
end
|
|
105
81
|
end
|
|
@@ -16,13 +16,10 @@ module Webrat
|
|
|
16
16
|
# Webrat can be configured using the Webrat.configure method. For example:
|
|
17
17
|
#
|
|
18
18
|
# Webrat.configure do |config|
|
|
19
|
-
# config.
|
|
19
|
+
# config.mode = :sinatra
|
|
20
20
|
# end
|
|
21
21
|
class Configuration
|
|
22
22
|
|
|
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
23
|
# Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc.
|
|
27
24
|
attr_reader :mode # :nodoc:
|
|
28
25
|
|
|
@@ -63,7 +60,6 @@ module Webrat
|
|
|
63
60
|
|
|
64
61
|
def initialize # :nodoc:
|
|
65
62
|
self.open_error_files = true
|
|
66
|
-
self.parse_with_nokogiri = true
|
|
67
63
|
self.application_environment = :test
|
|
68
64
|
self.application_port = 3001
|
|
69
65
|
self.application_address = 'localhost'
|
|
@@ -74,10 +70,6 @@ module Webrat
|
|
|
74
70
|
self.selenium_browser_startup_timeout = 5
|
|
75
71
|
end
|
|
76
72
|
|
|
77
|
-
def parse_with_nokogiri? #:nodoc:
|
|
78
|
-
@parse_with_nokogiri ? true : false
|
|
79
|
-
end
|
|
80
|
-
|
|
81
73
|
def open_error_files? #:nodoc:
|
|
82
74
|
@open_error_files ? true : false
|
|
83
75
|
end
|
|
@@ -87,13 +79,11 @@ module Webrat
|
|
|
87
79
|
def mode=(mode)
|
|
88
80
|
@mode = mode.to_sym
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
else
|
|
96
|
-
require("webrat/#{mode}")
|
|
82
|
+
begin
|
|
83
|
+
require("webrat/integrations/#{mode}")
|
|
84
|
+
rescue LoadError
|
|
85
|
+
# Only some modes have integration code that needs to
|
|
86
|
+
# be loaded, so this is OK
|
|
97
87
|
end
|
|
98
88
|
end
|
|
99
89
|
|
|
@@ -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
|