webrat 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. data/.document +4 -0
  2. data/.gitignore +15 -0
  3. data/History.txt +44 -8
  4. data/Rakefile +80 -66
  5. data/VERSION +1 -0
  6. data/lib/webrat.rb +7 -12
  7. data/lib/webrat/core/configuration.rb +7 -3
  8. data/lib/webrat/core/elements/area.rb +7 -7
  9. data/lib/webrat/core/elements/element.rb +11 -11
  10. data/lib/webrat/core/elements/field.rb +63 -55
  11. data/lib/webrat/core/elements/form.rb +17 -17
  12. data/lib/webrat/core/elements/label.rb +6 -6
  13. data/lib/webrat/core/elements/link.rb +13 -12
  14. data/lib/webrat/core/elements/select_option.rb +9 -9
  15. data/lib/webrat/core/locators.rb +2 -2
  16. data/lib/webrat/core/locators/area_locator.rb +10 -10
  17. data/lib/webrat/core/locators/button_locator.rb +13 -13
  18. data/lib/webrat/core/locators/field_by_id_locator.rb +8 -8
  19. data/lib/webrat/core/locators/field_labeled_locator.rb +11 -11
  20. data/lib/webrat/core/locators/field_locator.rb +7 -7
  21. data/lib/webrat/core/locators/field_named_locator.rb +10 -10
  22. data/lib/webrat/core/locators/form_locator.rb +6 -6
  23. data/lib/webrat/core/locators/label_locator.rb +9 -9
  24. data/lib/webrat/core/locators/link_locator.rb +21 -13
  25. data/lib/webrat/core/locators/locator.rb +5 -5
  26. data/lib/webrat/core/locators/select_option_locator.rb +11 -11
  27. data/lib/webrat/core/logging.rb +7 -4
  28. data/lib/webrat/core/matchers/have_content.rb +12 -12
  29. data/lib/webrat/core/matchers/have_selector.rb +9 -9
  30. data/lib/webrat/core/matchers/have_tag.rb +4 -4
  31. data/lib/webrat/core/matchers/have_xpath.rb +26 -26
  32. data/lib/webrat/core/methods.rb +13 -11
  33. data/lib/webrat/core/mime.rb +3 -3
  34. data/lib/webrat/core/save_and_open_page.rb +14 -16
  35. data/lib/webrat/core/scope.rb +53 -53
  36. data/lib/webrat/core/session.rb +23 -14
  37. data/lib/webrat/core/xml.rb +16 -16
  38. data/lib/webrat/core/xml/hpricot.rb +3 -3
  39. data/lib/webrat/core/xml/nokogiri.rb +11 -11
  40. data/lib/webrat/core/xml/rexml.rb +3 -3
  41. data/lib/webrat/core_extensions/blank.rb +1 -1
  42. data/lib/webrat/core_extensions/deprecate.rb +1 -1
  43. data/lib/webrat/core_extensions/detect_mapped.rb +4 -4
  44. data/lib/webrat/core_extensions/meta_class.rb +1 -1
  45. data/lib/webrat/core_extensions/tcp_socket.rb +8 -8
  46. data/lib/webrat/mechanize.rb +9 -9
  47. data/lib/webrat/merb.rb +1 -1
  48. data/lib/webrat/merb_multipart_support.rb +27 -0
  49. data/lib/webrat/merb_session.rb +39 -24
  50. data/lib/webrat/rack_test.rb +32 -0
  51. data/lib/webrat/rails.rb +2 -2
  52. data/lib/webrat/rspec-rails.rb +3 -6
  53. data/lib/webrat/selenium.rb +2 -1
  54. data/lib/webrat/selenium/application_server_factory.rb +40 -0
  55. data/lib/webrat/selenium/application_servers.rb +5 -0
  56. data/lib/webrat/selenium/application_servers/base.rb +46 -0
  57. data/lib/webrat/selenium/application_servers/external.rb +26 -0
  58. data/lib/webrat/selenium/application_servers/merb.rb +50 -0
  59. data/lib/webrat/selenium/application_servers/rails.rb +44 -0
  60. data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
  61. data/lib/webrat/selenium/location_strategy_javascript/button.js +14 -7
  62. data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +4 -1
  63. data/lib/webrat/selenium/matchers.rb +1 -1
  64. data/lib/webrat/selenium/matchers/have_content.rb +4 -4
  65. data/lib/webrat/selenium/matchers/have_selector.rb +4 -4
  66. data/lib/webrat/selenium/matchers/have_tag.rb +16 -16
  67. data/lib/webrat/selenium/matchers/have_xpath.rb +4 -4
  68. data/lib/webrat/selenium/selenium_rc_server.rb +25 -19
  69. data/lib/webrat/selenium/selenium_session.rb +24 -17
  70. data/lib/webrat/selenium/silence_stream.rb +18 -0
  71. data/spec/fakes/test_session.rb +34 -0
  72. data/spec/integration/merb/.gitignore +21 -0
  73. data/spec/integration/merb/Rakefile +35 -0
  74. data/spec/integration/merb/app/controllers/application.rb +2 -0
  75. data/spec/integration/merb/app/controllers/exceptions.rb +13 -0
  76. data/spec/integration/merb/app/controllers/testing.rb +27 -0
  77. data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
  78. data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
  79. data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
  80. data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
  81. data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
  82. data/spec/integration/merb/config/environments/development.rb +15 -0
  83. data/spec/integration/merb/config/environments/rake.rb +11 -0
  84. data/spec/integration/merb/config/environments/test.rb +14 -0
  85. data/spec/integration/merb/config/init.rb +25 -0
  86. data/spec/integration/merb/config/rack.rb +11 -0
  87. data/spec/integration/merb/config/router.rb +34 -0
  88. data/spec/integration/merb/spec/spec.opts +1 -0
  89. data/spec/integration/merb/spec/spec_helper.rb +24 -0
  90. data/spec/integration/merb/spec/webrat_spec.rb +39 -0
  91. data/spec/integration/merb/tasks/merb.thor/app_script.rb +31 -0
  92. data/spec/integration/merb/tasks/merb.thor/common.rb +64 -0
  93. data/spec/integration/merb/tasks/merb.thor/gem_ext.rb +124 -0
  94. data/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
  95. data/spec/integration/merb/tasks/merb.thor/ops.rb +93 -0
  96. data/spec/integration/merb/tasks/merb.thor/utils.rb +40 -0
  97. data/spec/integration/rack/Rakefile +5 -0
  98. data/spec/integration/rack/rack_app.rb +16 -0
  99. data/spec/integration/rack/test/test_helper.rb +20 -0
  100. data/spec/integration/rack/test/webrat_rack_test.rb +67 -0
  101. data/spec/integration/rails/.gitignore +3 -0
  102. data/spec/integration/rails/Rakefile +30 -0
  103. data/spec/integration/rails/app/controllers/application.rb +15 -0
  104. data/spec/integration/rails/app/controllers/buttons_controller.rb +7 -0
  105. data/spec/integration/rails/app/controllers/fields_controller.rb +4 -0
  106. data/spec/integration/rails/app/controllers/links_controller.rb +7 -0
  107. data/spec/integration/rails/app/controllers/webrat_controller.rb +43 -0
  108. data/spec/integration/rails/app/helpers/buttons_helper.rb +2 -0
  109. data/spec/integration/rails/app/helpers/fields_helper.rb +2 -0
  110. data/spec/integration/rails/app/helpers/links_helper.rb +2 -0
  111. data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
  112. data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
  113. data/spec/integration/rails/app/views/links/show.html.erb +5 -0
  114. data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
  115. data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
  116. data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
  117. data/spec/integration/rails/config/boot.rb +109 -0
  118. data/spec/integration/rails/config/environment.rb +12 -0
  119. data/spec/integration/rails/config/environments/development.rb +17 -0
  120. data/spec/integration/rails/config/environments/selenium.rb +22 -0
  121. data/spec/integration/rails/config/environments/test.rb +22 -0
  122. data/spec/integration/rails/config/initializers/inflections.rb +10 -0
  123. data/spec/integration/rails/config/initializers/mime_types.rb +5 -0
  124. data/spec/integration/rails/config/initializers/new_rails_defaults.rb +17 -0
  125. data/spec/integration/rails/config/locales/en.yml +5 -0
  126. data/spec/integration/rails/config/routes.rb +18 -0
  127. data/spec/integration/rails/public/404.html +30 -0
  128. data/spec/integration/rails/public/422.html +30 -0
  129. data/spec/integration/rails/public/500.html +33 -0
  130. data/spec/integration/rails/script/about +4 -0
  131. data/spec/integration/rails/script/console +3 -0
  132. data/spec/integration/rails/script/dbconsole +3 -0
  133. data/spec/integration/rails/script/destroy +3 -0
  134. data/spec/integration/rails/script/generate +3 -0
  135. data/spec/integration/rails/script/performance/benchmarker +3 -0
  136. data/spec/integration/rails/script/performance/profiler +3 -0
  137. data/spec/integration/rails/script/performance/request +3 -0
  138. data/spec/integration/rails/script/plugin +3 -0
  139. data/spec/integration/rails/script/process/inspector +3 -0
  140. data/spec/integration/rails/script/process/reaper +3 -0
  141. data/spec/integration/rails/script/process/spawner +3 -0
  142. data/spec/integration/rails/script/runner +3 -0
  143. data/spec/integration/rails/script/server +3 -0
  144. data/spec/integration/rails/test/integration/button_click_test.rb +80 -0
  145. data/spec/integration/rails/test/integration/fill_in_test.rb +24 -0
  146. data/spec/integration/rails/test/integration/link_click_test.rb +27 -0
  147. data/spec/integration/rails/test/integration/webrat_test.rb +97 -0
  148. data/spec/integration/rails/test/test_helper.rb +25 -0
  149. data/spec/integration/sinatra/Rakefile +5 -0
  150. data/spec/integration/sinatra/classic_app.rb +64 -0
  151. data/spec/integration/sinatra/modular_app.rb +16 -0
  152. data/spec/integration/sinatra/test/classic_app_test.rb +37 -0
  153. data/spec/integration/sinatra/test/modular_app_test.rb +18 -0
  154. data/spec/integration/sinatra/test/test_helper.rb +16 -0
  155. data/spec/private/core/configuration_spec.rb +116 -0
  156. data/spec/private/core/field_spec.rb +85 -0
  157. data/spec/private/core/link_spec.rb +24 -0
  158. data/spec/private/core/logging_spec.rb +10 -0
  159. data/spec/private/core/session_spec.rb +195 -0
  160. data/spec/private/mechanize/mechanize_session_spec.rb +81 -0
  161. data/spec/private/merb/attaches_file_spec.rb +93 -0
  162. data/spec/private/merb/merb_session_spec.rb +61 -0
  163. data/spec/private/nokogiri_spec.rb +77 -0
  164. data/spec/private/rails/attaches_file_spec.rb +81 -0
  165. data/spec/private/rails/rails_session_spec.rb +110 -0
  166. data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
  167. data/spec/public/basic_auth_spec.rb +24 -0
  168. data/spec/public/check_spec.rb +191 -0
  169. data/spec/public/choose_spec.rb +118 -0
  170. data/spec/public/click_area_spec.rb +106 -0
  171. data/spec/public/click_button_spec.rb +496 -0
  172. data/spec/public/click_link_spec.rb +511 -0
  173. data/spec/public/fill_in_spec.rb +209 -0
  174. data/spec/public/locators/field_by_xpath_spec.rb +19 -0
  175. data/spec/public/locators/field_labeled_spec.rb +172 -0
  176. data/spec/public/locators/field_with_id_spec.rb +16 -0
  177. data/spec/public/matchers/contain_spec.rb +114 -0
  178. data/spec/public/matchers/have_selector_spec.rb +142 -0
  179. data/spec/public/matchers/have_tag_spec.rb +39 -0
  180. data/spec/public/matchers/have_xpath_spec.rb +136 -0
  181. data/spec/public/reload_spec.rb +10 -0
  182. data/spec/public/save_and_open_spec.rb +70 -0
  183. data/spec/public/select_date_spec.rb +112 -0
  184. data/spec/public/select_datetime_spec.rb +137 -0
  185. data/spec/public/select_spec.rb +249 -0
  186. data/spec/public/select_time_spec.rb +100 -0
  187. data/spec/public/selenium/application_server_factory_spec.rb +49 -0
  188. data/spec/public/selenium/application_servers/external_spec.rb +12 -0
  189. data/spec/public/selenium/selenium_session_spec.rb +37 -0
  190. data/spec/public/set_hidden_field_spec.rb +5 -0
  191. data/spec/public/submit_form_spec.rb +5 -0
  192. data/spec/public/visit_spec.rb +58 -0
  193. data/spec/public/within_spec.rb +177 -0
  194. data/spec/rcov.opts +1 -0
  195. data/spec/spec.opts +2 -0
  196. data/spec/spec_helper.rb +50 -0
  197. data/vendor/selenium-server.jar +0 -0
  198. data/webrat.gemspec +340 -0
  199. metadata +248 -33
  200. data/lib/webrat/selenium/application_server.rb +0 -71
  201. data/lib/webrat/selenium/merb_application_server.rb +0 -48
  202. data/lib/webrat/selenium/rails_application_server.rb +0 -42
  203. data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
data/.document ADDED
@@ -0,0 +1,4 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ History.txt
4
+ MIT-LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ coverage
2
+ .DS_Store
3
+ pkg
4
+ doc
5
+ ri
6
+ email.txt
7
+ .svn
8
+ log
9
+ .project
10
+ .loadpath
11
+ *.swp
12
+ results
13
+ test_apps
14
+ *.tmproj
15
+ *.log
data/History.txt CHANGED
@@ -1,11 +1,46 @@
1
+ == 0.4.5 / 2009-08-10
2
+
3
+ * Major enhancements
4
+
5
+ * Ruby 1.9 compatibility (Michael Fellinger, Jakub Kuźma)
6
+ * Improve performance (~2x) on JRuby by supporting Nokogiri
7
+ * Added support for external app servers in selenium mode (basically don't start one) (Mike Gaffney)
8
+ * Added support for uploading files for Merb (Ryan Carver)
9
+
10
+ * Minor enhancements
11
+
12
+ * Upgrade to selenium-client to 1.2.16 (Brian Landau)
13
+ * Upgrade selenium-server.jar to 1.0.1 (Brian Landau)
14
+ * Make redirect detection work in the face of rational maths (like when ruby-units is active) (Piers Cawley)
15
+ * Use Launchy to handle opening pages in the browser with cross-platform compatibility (Bryan Helmkamp)
16
+ * Added support for field_labeled_locators ending in non word characters
17
+ lh 148 (Zach Dennis)
18
+ * Filled in tests on click link lh 195 (diabolo)
19
+ * Added current_url to selenium session lh 215 (Luke Amdor)
20
+ * Added silence spec to selenium lh 238 (Martin Gamsjaeger aka snusnu)
21
+ * Added ability to configure the browser startup timeout for selenium lh 242 (Mike Gaffney, Mark Dodwell)
22
+ * Added delegation for field_named lh194 (pivotal labs)
23
+ * Added fix to keep from escaping field values in mechanize mode lh256 (jish)
24
+ * Adding fixes for click button/link and made the integration specs pass for the same in selenium lh254 (Ldiehl, Matthias Marschall)
25
+ * Adding clicking link by id in selenium mode lh221 (larrytheliquid)
26
+ * Adding fix for have_selector and have_xpath in descendent blocks lh234 (Thomas Jack)
27
+ * Adding fix for fields with labels with special characters (Thomas Jack, Mike Gaffney, Bryan Hemlkamp)
28
+ * Deprecated current_page lh50 (Mike Gaffney)
29
+ * Fixed issue with redirects and multiple hosts lh168 (Mutwin Kraus)
30
+
31
+ * Bug fixes
32
+
33
+ * Wait for application servers socket on 0.0.0.0 instead of the application_address
34
+ * Translate CSS and image paths with single quotes in save_and_open_page (Erin Staniland)
35
+
1
36
  == 0.4.4 / 2009-04-06
2
37
 
3
38
  * Major enhancements
4
39
 
5
40
  * Make selenium process management code more robust and informative
6
-
41
+
7
42
  * Minor enhancements
8
-
43
+
9
44
  * Add support for Rails javascript post links (Mark Menard)
10
45
  * Upgrade selenium-client dependency to 1.2.14, and update for new waiting
11
46
  API (Balint Erdi)
@@ -15,7 +50,8 @@
15
50
 
16
51
  * Don't create a new instance of WWW::Mechanize for each request
17
52
  (Mark Menard)
18
-
53
+ * Select fields with duplicate selected options sent an incorrect value (Noah Davis)
54
+
19
55
  == 0.4.3 / 2009-03-17
20
56
 
21
57
  * Minor enhancements
@@ -25,7 +61,7 @@
25
61
  * Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
26
62
  * When faced with a label with no for attribute, that contains a hidden field
27
63
  and another field, as can be the case in Rails 2.3's checkbox view,
28
- webrat now locates the non-hidden field. (Luke Melia)
64
+ webrat now locates the non-hidden field. (Luke Melia)
29
65
  * Add application_framework config for Selenium mode to determine how to
30
66
  start and stop the app server (Corey Donohoe)
31
67
 
@@ -41,7 +77,7 @@
41
77
  attributes in a hash and :count and :content options. See
42
78
  have_selector_spec.rb for more.
43
79
  * Add the same functionality mentioned above to have_xpath
44
-
80
+
45
81
  * Minor enhancements
46
82
 
47
83
  * Squeeze extra whitespace out of failures messages from contain
@@ -68,7 +104,7 @@
68
104
  redirected to (Adam Greene)
69
105
  * Recognize input tags with type button (Lena Herrmann)
70
106
  * Add uncheck method to Selenium mode (Lee Bankewitz)
71
-
107
+
72
108
  * Bug fixes
73
109
 
74
110
  * Make requests to a Rails app using a full URL instead of a relative path. This change
@@ -79,7 +115,7 @@
79
115
  to behave correctly (Noah Davis)
80
116
  * Switch to using selenium.click instead of .check when checking a checkbox
81
117
  (Noah Davis)
82
- * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
118
+ * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
83
119
  * Setup deprecated writers for the selenium_environment= and selenium_port= config
84
120
  * Ensure the previous pages params aren't passed through redirect (Daniel Lucraft and
85
121
  Bryan Helmkamp)
@@ -155,7 +191,7 @@
155
191
  * Added save_and_open_screengrab for Selenium mode (Luke Melia)
156
192
 
157
193
  * Bug fixes
158
-
194
+
159
195
  * field_labeled should disregard labels without matching fields (Kyle Hargraves)
160
196
  * Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
161
197
  [#105] (Zach Dennis)
data/Rakefile CHANGED
@@ -1,54 +1,32 @@
1
- # require 'rubygems'
2
- require "rake/gempackagetask"
3
- require 'rake/rdoctask'
4
- require "rake/clean"
5
- require 'spec'
6
- require 'spec/rake/spectask'
7
- require 'spec/rake/verify_rcov'
8
- require File.expand_path('./lib/webrat.rb')
9
-
10
- ##############################################################################
11
- # Package && release
12
- ##############################################################################
13
- spec = Gem::Specification.new do |s|
14
- s.name = "webrat"
15
- s.version = Webrat::VERSION
16
- s.platform = Gem::Platform::RUBY
17
- s.author = "Bryan Helmkamp"
18
- s.email = "bryan" + "@" + "brynary.com"
19
- s.homepage = "http://github.com/brynary/webrat"
20
- s.summary = "Webrat. Ruby Acceptance Testing for Web applications"
21
- s.bindir = "bin"
22
- s.description = s.summary
23
- s.require_path = "lib"
24
- s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["vendor/**/*"]
25
-
26
- # rdoc
27
- s.has_rdoc = true
28
- s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
29
-
30
- # Dependencies
31
- s.add_dependency "nokogiri", ">= 1.2.0"
32
-
33
- s.rubyforge_project = "webrat"
34
- end
1
+ begin
2
+ require 'jeweler'
35
3
 
36
- Rake::GemPackageTask.new(spec) do |package|
37
- package.gem_spec = spec
38
- end
4
+ Jeweler::Tasks.new do |s|
5
+ s.name = "webrat"
6
+ s.author = "Bryan Helmkamp"
7
+ s.email = "bryan" + "@" + "brynary.com"
8
+ s.homepage = "http://github.com/brynary/webrat"
9
+ s.summary = "Ruby Acceptance Testing for Web applications"
10
+ # s.description = "TODO"
39
11
 
40
- desc 'Show information about the gem.'
41
- task :debug_gem do
42
- puts spec.to_ruby
43
- end
12
+ s.rubyforge_project = "webrat"
13
+ s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
44
14
 
45
- CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
15
+ # Dependencies
16
+ s.add_dependency "nokogiri", ">= 1.2.0"
46
17
 
47
- desc "Upload rdoc to brynary.com"
48
- task :publish_rdoc => :docs do
49
- sh "scp -r doc/ brynary.com:/apps/uploads/webrat"
18
+ # TODO: Add development dependencies
19
+ end
20
+
21
+ Jeweler::RubyforgeTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler not available. Install it with: gem install jeweler"
50
24
  end
51
25
 
26
+ # require 'spec'
27
+ require 'spec/rake/spectask'
28
+ require 'spec/rake/verify_rcov'
29
+
52
30
  desc "Run API and Core specs"
53
31
  Spec::Rake::SpecTask.new do |t|
54
32
  t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
@@ -69,26 +47,47 @@ RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
69
47
  t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
70
48
  end
71
49
 
72
- desc 'Install the package as a gem.'
73
- task :install_gem => [:clean, :package] do
74
- gem_filename = Dir['pkg/*.gem'].first
75
- sh "sudo gem install --no-rdoc --no-ri --local #{gem_filename}"
76
- end
50
+ desc "Run everything against multiruby"
51
+ task :multiruby do
52
+ result = system "multiruby -S rake spec"
53
+ raise "Multiruby tests failed" unless result
54
+ result = system "jruby -S rake spec"
55
+ raise "JRuby tests failed" unless result
77
56
 
78
- desc "Delete generated RDoc"
79
- task :clobber_docs do
80
- FileUtils.rm_rf("doc")
81
- end
57
+ Dir.chdir "spec/integration/rails" do
58
+ result = system "multiruby -S rake test_unit:rails"
59
+ raise "Rails integration tests failed" unless result
82
60
 
83
- desc "Generate RDoc"
84
- task :docs => :clobber_docs do
85
- system "hanna --title 'Webrat #{Webrat::VERSION} API Documentation'"
86
- end
61
+ result = system "jruby -S rake test_unit:rails"
62
+ raise "Rails integration tests failed" unless result
63
+ end
87
64
 
88
- desc "Run specs using jruby"
89
- task "spec:jruby" do
90
- result = system "jruby -S rake spec"
91
- raise "JRuby tests failed" unless result
65
+ Dir.chdir "spec/integration/merb" do
66
+ result = system "multiruby -S rake spec"
67
+ raise "Merb integration tests failed" unless result
68
+
69
+ result = system "jruby -S rake spec"
70
+ raise "Rails integration tests failed" unless result
71
+ end
72
+
73
+ Dir.chdir "spec/integration/sinatra" do
74
+ result = system "multiruby -S rake test"
75
+ raise "Sinatra integration tests failed" unless result
76
+
77
+ result = system "jruby -S rake test"
78
+ raise "Sinatra integration tests failed" unless result
79
+ end
80
+
81
+ Dir.chdir "spec/integration/rack" do
82
+ result = system "multiruby -S rake test"
83
+ raise "Rack integration tests failed" unless result
84
+
85
+ result = system "jruby -S rake test"
86
+ raise "Rack integration tests failed" unless result
87
+ end
88
+
89
+ puts
90
+ puts "Multiruby OK!"
92
91
  end
93
92
 
94
93
  desc "Run each spec in isolation to test for dependency issues"
@@ -106,7 +105,7 @@ end
106
105
 
107
106
  namespace :spec do
108
107
  desc "Run the integration specs"
109
- task :integration => ["integration:rails", "integration:merb", "integration:sinatra"]
108
+ task :integration => ["integration:rails", "integration:merb", "integration:sinatra", "integration:rack"]
110
109
 
111
110
  namespace :integration do
112
111
  desc "Run the Rails integration specs"
@@ -140,12 +139,27 @@ namespace :spec do
140
139
  task :sinatra do
141
140
  Dir.chdir "spec/integration/sinatra" do
142
141
  result = system "rake test"
143
- raise "Sinatra tntegration tests failed" unless result
142
+ raise "Sinatra integration tests failed" unless result
143
+ end
144
+ end
145
+
146
+ desc "Run the Sinatra integration specs"
147
+ task :rack do
148
+ Dir.chdir "spec/integration/rack" do
149
+ result = system "rake test"
150
+ raise "Rack integration tests failed" unless result
144
151
  end
145
152
  end
146
153
  end
147
154
  end
148
155
 
149
- task :default => :spec
156
+ desc 'Removes trailing whitespace'
157
+ task :whitespace do
158
+ sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
159
+ end
160
+
161
+ if defined?(Jeweler)
162
+ task :spec => :check_dependencies
163
+ end
150
164
 
151
- task :precommit => ["spec", "spec:jruby", "spec:integration"]
165
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.4.5
data/lib/webrat.rb CHANGED
@@ -7,26 +7,21 @@ module Webrat
7
7
  class WebratError < StandardError
8
8
  end
9
9
 
10
- VERSION = '0.4.4'
11
-
12
10
  def self.require_xml
13
- gem "nokogiri", ">= 1.0.6"
14
-
15
11
  if on_java?
16
- # We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
17
- require "nokogiri/css"
18
- require "hpricot"
19
- require "rexml/document"
12
+ gem "nokogiri", ">= 1.2.4"
20
13
  else
21
- require "nokogiri"
22
- require "webrat/core/xml/nokogiri"
14
+ gem "nokogiri", ">= 1.0.6"
23
15
  end
16
+
17
+ require "nokogiri"
18
+ require "webrat/core/xml/nokogiri"
24
19
  end
25
-
20
+
26
21
  def self.on_java?
27
22
  RUBY_PLATFORM =~ /java/
28
23
  end
29
-
24
+
30
25
  end
31
26
 
32
27
  Webrat.require_xml
@@ -54,13 +54,16 @@ module Webrat
54
54
  # Set the key that Selenium uses to determine the browser running. Default *firefox
55
55
  attr_accessor :selenium_browser_key
56
56
 
57
+ # Set the timeout for waiting for the browser process to start
58
+ attr_accessor :selenium_browser_startup_timeout
59
+
57
60
  # How many redirects to the same URL should be halted as an infinite redirect
58
61
  # loop? Defaults to 10
59
62
  attr_accessor :infinite_redirect_limit
60
-
63
+
61
64
  def initialize # :nodoc:
62
65
  self.open_error_files = true
63
- self.parse_with_nokogiri = !Webrat.on_java?
66
+ self.parse_with_nokogiri = true
64
67
  self.application_environment = :test
65
68
  self.application_port = 3001
66
69
  self.application_address = 'localhost'
@@ -68,6 +71,7 @@ module Webrat
68
71
  self.selenium_server_port = 4444
69
72
  self.infinite_redirect_limit = 10
70
73
  self.selenium_browser_key = '*firefox'
74
+ self.selenium_browser_startup_timeout = 5
71
75
  end
72
76
 
73
77
  def parse_with_nokogiri? #:nodoc:
@@ -82,7 +86,7 @@ module Webrat
82
86
  # :rails, :selenium, :rack, :sinatra, :mechanize, :merb
83
87
  def mode=(mode)
84
88
  @mode = mode.to_sym
85
-
89
+
86
90
  # This is a temporary hack to support backwards compatibility
87
91
  # with Merb 1.0.8 until it's updated to use the new Webrat.configure
88
92
  # syntax
@@ -2,21 +2,21 @@ require "webrat/core/elements/element"
2
2
 
3
3
  module Webrat
4
4
  class Area < Element #:nodoc:
5
-
5
+
6
6
  def self.xpath_search
7
7
  ".//area"
8
8
  end
9
-
9
+
10
10
  def click(method = nil, options = {})
11
11
  @session.request_page(absolute_href, :get, {})
12
12
  end
13
-
13
+
14
14
  protected
15
-
15
+
16
16
  def href
17
17
  Webrat::XML.attribute(@element, "href")
18
18
  end
19
-
19
+
20
20
  def absolute_href
21
21
  if href =~ /^\?/
22
22
  "#{@session.current_url}#{href}"
@@ -26,6 +26,6 @@ module Webrat
26
26
  href
27
27
  end
28
28
  end
29
-
29
+
30
30
  end
31
- end
31
+ end
@@ -1,33 +1,33 @@
1
1
  module Webrat
2
-
2
+
3
3
  class Element # :nodoc:
4
-
4
+
5
5
  def self.load_all(session, dom)
6
- Webrat::XML.xpath_search(dom, xpath_search).map do |element|
6
+ Webrat::XML.xpath_search(dom, 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
13
  session.elements[Webrat::XML.xpath_to(element)] ||= self.new(session, element)
14
14
  end
15
-
15
+
16
16
  attr_reader :element
17
-
17
+
18
18
  def initialize(session, element)
19
19
  @session = session
20
20
  @element = element
21
21
  end
22
-
22
+
23
23
  def path
24
24
  Webrat::XML.xpath_to(@element)
25
25
  end
26
-
26
+
27
27
  def inspect
28
28
  "#<#{self.class} @element=#{element.inspect}>"
29
29
  end
30
-
30
+
31
31
  end
32
-
33
- end
32
+
33
+ end