diabolo-webrat 0.4.4.2 → 0.5.1

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.
Files changed (148) hide show
  1. data/.document +4 -0
  2. data/.gitignore +15 -0
  3. data/History.txt +60 -9
  4. data/Rakefile +90 -75
  5. data/VERSION +1 -0
  6. data/lib/webrat.rb +8 -23
  7. data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +6 -2
  8. data/lib/webrat/adapters/merb.rb +11 -0
  9. data/lib/webrat/adapters/rack.rb +25 -0
  10. data/lib/webrat/{rails.rb → adapters/rails.rb} +9 -18
  11. data/lib/webrat/adapters/sinatra.rb +9 -0
  12. data/lib/webrat/core.rb +0 -1
  13. data/lib/webrat/core/configuration.rb +7 -17
  14. data/lib/webrat/core/elements/area.rb +2 -2
  15. data/lib/webrat/core/elements/element.rb +3 -3
  16. data/lib/webrat/core/elements/field.rb +33 -30
  17. data/lib/webrat/core/elements/form.rb +4 -4
  18. data/lib/webrat/core/elements/label.rb +4 -4
  19. data/lib/webrat/core/elements/link.rb +7 -6
  20. data/lib/webrat/core/elements/select_option.rb +2 -2
  21. data/lib/webrat/core/locators.rb +1 -1
  22. data/lib/webrat/core/locators/area_locator.rb +3 -3
  23. data/lib/webrat/core/locators/button_locator.rb +6 -6
  24. data/lib/webrat/core/locators/field_by_id_locator.rb +3 -3
  25. data/lib/webrat/core/locators/field_labeled_locator.rb +2 -2
  26. data/lib/webrat/core/locators/field_named_locator.rb +3 -3
  27. data/lib/webrat/core/locators/form_locator.rb +1 -1
  28. data/lib/webrat/core/locators/label_locator.rb +2 -2
  29. data/lib/webrat/core/locators/link_locator.rb +20 -12
  30. data/lib/webrat/core/locators/select_option_locator.rb +5 -5
  31. data/lib/webrat/core/logging.rb +1 -1
  32. data/lib/webrat/core/matchers/have_content.rb +2 -7
  33. data/lib/webrat/core/matchers/have_xpath.rb +2 -27
  34. data/lib/webrat/core/methods.rb +4 -4
  35. data/lib/webrat/core/mime.rb +11 -22
  36. data/lib/webrat/core/save_and_open_page.rb +5 -7
  37. data/lib/webrat/core/scope.rb +2 -2
  38. data/lib/webrat/core/session.rb +30 -14
  39. data/lib/webrat/core/xml.rb +41 -84
  40. data/lib/webrat/integrations/merb.rb +10 -0
  41. data/lib/webrat/integrations/rails.rb +9 -0
  42. data/lib/webrat/integrations/rspec-rails.rb +10 -0
  43. data/lib/webrat/integrations/selenium.rb +11 -0
  44. data/lib/webrat/rspec-rails.rb +2 -13
  45. data/lib/webrat/selenium.rb +0 -11
  46. data/lib/webrat/selenium/application_server_factory.rb +40 -0
  47. data/lib/webrat/selenium/application_servers.rb +5 -0
  48. data/lib/webrat/selenium/application_servers/base.rb +46 -0
  49. data/lib/webrat/selenium/application_servers/external.rb +26 -0
  50. data/lib/webrat/selenium/application_servers/merb.rb +50 -0
  51. data/lib/webrat/selenium/application_servers/rails.rb +44 -0
  52. data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
  53. data/lib/webrat/selenium/location_strategy_javascript/label.js +2 -1
  54. data/lib/webrat/selenium/selenium_rc_server.rb +7 -5
  55. data/lib/webrat/selenium/selenium_session.rb +20 -7
  56. data/lib/webrat/selenium/silence_stream.rb +1 -1
  57. data/spec/fakes/{test_session.rb → test_adapter.rb} +6 -3
  58. data/spec/integration/mechanize/Rakefile +7 -0
  59. data/spec/integration/mechanize/config.ru +2 -0
  60. data/spec/integration/mechanize/sample_app.rb +20 -0
  61. data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
  62. data/spec/integration/mechanize/spec/spec_helper.rb +27 -0
  63. data/spec/integration/merb/.gitignore +21 -0
  64. data/spec/integration/merb/Rakefile +35 -0
  65. data/spec/integration/merb/app/controllers/testing.rb +9 -0
  66. data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
  67. data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
  68. data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
  69. data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
  70. data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
  71. data/spec/integration/merb/config/router.rb +1 -0
  72. data/spec/integration/merb/spec/spec.opts +1 -0
  73. data/spec/integration/merb/spec/spec_helper.rb +2 -0
  74. data/spec/integration/merb/spec/webrat_spec.rb +7 -0
  75. data/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
  76. data/spec/integration/rack/Rakefile +5 -0
  77. data/spec/integration/rack/app.rb +89 -0
  78. data/spec/integration/rack/test/helper.rb +21 -0
  79. data/spec/integration/rack/test/webrat_rack_test.rb +57 -51
  80. data/spec/integration/rails/.gitignore +3 -0
  81. data/spec/integration/rails/Rakefile +30 -0
  82. data/spec/integration/rails/app/controllers/webrat_controller.rb +13 -9
  83. data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
  84. data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
  85. data/spec/integration/rails/app/views/links/show.html.erb +5 -0
  86. data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
  87. data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
  88. data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
  89. data/spec/integration/rails/config/locales/en.yml +5 -0
  90. data/spec/integration/rails/config/routes.rb +1 -0
  91. data/spec/integration/rails/public/404.html +30 -0
  92. data/spec/integration/rails/public/422.html +30 -0
  93. data/spec/integration/rails/public/500.html +33 -0
  94. data/spec/integration/rails/script/about +4 -0
  95. data/spec/integration/rails/script/console +3 -0
  96. data/spec/integration/rails/script/dbconsole +3 -0
  97. data/spec/integration/rails/script/destroy +3 -0
  98. data/spec/integration/rails/script/generate +3 -0
  99. data/spec/integration/rails/script/performance/benchmarker +3 -0
  100. data/spec/integration/rails/script/performance/profiler +3 -0
  101. data/spec/integration/rails/script/performance/request +3 -0
  102. data/spec/integration/rails/script/plugin +3 -0
  103. data/spec/integration/rails/script/process/inspector +3 -0
  104. data/spec/integration/rails/script/process/reaper +3 -0
  105. data/spec/integration/rails/script/process/spawner +3 -0
  106. data/spec/integration/rails/script/runner +3 -0
  107. data/spec/integration/rails/script/server +3 -0
  108. data/spec/integration/rails/test/integration/button_click_test.rb +2 -2
  109. data/spec/integration/rails/test/integration/link_click_test.rb +7 -1
  110. data/spec/integration/rails/test/integration/webrat_test.rb +22 -0
  111. data/spec/integration/rails/test/test_helper.rb +6 -5
  112. data/spec/integration/sinatra/Rakefile +5 -0
  113. data/spec/integration/sinatra/test/test_helper.rb +3 -2
  114. data/spec/private/core/configuration_spec.rb +8 -27
  115. data/spec/private/core/field_spec.rb +7 -7
  116. data/spec/private/core/link_spec.rb +1 -1
  117. data/spec/private/core/session_spec.rb +23 -21
  118. data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -12
  119. data/spec/private/nokogiri_spec.rb +2 -2
  120. data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +16 -16
  121. data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
  122. data/spec/public/matchers/contain_spec.rb +4 -4
  123. data/spec/public/matchers/have_selector_spec.rb +2 -2
  124. data/spec/public/matchers/have_xpath_spec.rb +3 -3
  125. data/spec/public/save_and_open_spec.rb +25 -6
  126. data/spec/public/selenium/application_server_factory_spec.rb +49 -0
  127. data/spec/public/selenium/application_servers/external_spec.rb +12 -0
  128. data/spec/public/selenium/selenium_session_spec.rb +37 -0
  129. data/spec/rcov.opts +1 -0
  130. data/spec/spec.opts +2 -0
  131. data/spec/spec_helper.rb +5 -1
  132. data/vendor/selenium-server.jar +0 -0
  133. data/webrat.gemspec +348 -0
  134. metadata +176 -23
  135. data/lib/webrat/core/xml/hpricot.rb +0 -19
  136. data/lib/webrat/core/xml/nokogiri.rb +0 -76
  137. data/lib/webrat/core/xml/rexml.rb +0 -24
  138. data/lib/webrat/merb_session.rb +0 -65
  139. data/lib/webrat/rack.rb +0 -24
  140. data/lib/webrat/rack_test.rb +0 -32
  141. data/lib/webrat/selenium/application_server.rb +0 -73
  142. data/lib/webrat/selenium/merb_application_server.rb +0 -48
  143. data/lib/webrat/selenium/rails_application_server.rb +0 -42
  144. data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
  145. data/lib/webrat/sinatra.rb +0 -44
  146. data/spec/integration/rack/rack_app.rb +0 -16
  147. data/spec/integration/rack/test/test_helper.rb +0 -20
  148. data/spec/private/merb/merb_session_spec.rb +0 -42
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,55 @@
1
- == 0.4.5 / ?
1
+ == Git
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 it's 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
+ * Update the Merb support to be based directly on Rack (Simon Rozet)
16
+
17
+ == 0.5.1 / 2009-08-18
18
+
19
+ * Minor enhancements
20
+
21
+ * Base Webrat::MIME on Rack::Mime (Simon Rozet)
22
+ * Support file uploads in Rack mode (Simon Rozet)
23
+
24
+ * Bug fixes
25
+
26
+ * Fix bug in Webrat::Methods preventing Selenium mode from working [#277]
27
+
28
+ == 0.5.0 / 2009-08-12
29
+
30
+ * Major enhancements
31
+
32
+ * Depreacate :rack_test and :sinatra in favor of :rack, which uses Rack::Test (Simon Rozet)
33
+
34
+ * Minor enhancements
35
+
36
+ * Don't require rubygems at runtime (Simon Rozet)
37
+
38
+ == 0.4.5 / 2009-08-10
2
39
 
3
40
  * Major enhancements
4
41
 
42
+ * Ruby 1.9 compatibility (Michael Fellinger, Jakub Kuźma)
5
43
  * Improve performance (~2x) on JRuby by supporting Nokogiri
44
+ * Added support for external app servers in selenium mode (basically don't start one) (Mike Gaffney)
45
+ * Added support for uploading files for Merb (Ryan Carver)
6
46
 
7
47
  * Minor enhancements
8
48
 
49
+ * Upgrade to selenium-client to 1.2.16 (Brian Landau)
50
+ * Upgrade selenium-server.jar to 1.0.1 (Brian Landau)
51
+ * Make redirect detection work in the face of rational maths (like when ruby-units is active) (Piers Cawley)
52
+ * Use Launchy to handle opening pages in the browser with cross-platform compatibility (Bryan Helmkamp)
9
53
  * Added support for field_labeled_locators ending in non word characters
10
54
  lh 148 (Zach Dennis)
11
55
  * Filled in tests on click link lh 195 (diabolo)
@@ -18,15 +62,22 @@
18
62
  * Adding clicking link by id in selenium mode lh221 (larrytheliquid)
19
63
  * Adding fix for have_selector and have_xpath in descendent blocks lh234 (Thomas Jack)
20
64
  * Adding fix for fields with labels with special characters (Thomas Jack, Mike Gaffney, Bryan Hemlkamp)
65
+ * Deprecated current_page lh50 (Mike Gaffney)
66
+ * Fixed issue with redirects and multiple hosts lh168 (Mutwin Kraus)
67
+
68
+ * Bug fixes
69
+
70
+ * Wait for application servers socket on 0.0.0.0 instead of the application_address
71
+ * Translate CSS and image paths with single quotes in save_and_open_page (Erin Staniland)
21
72
 
22
73
  == 0.4.4 / 2009-04-06
23
74
 
24
75
  * Major enhancements
25
76
 
26
77
  * Make selenium process management code more robust and informative
27
-
78
+
28
79
  * Minor enhancements
29
-
80
+
30
81
  * Add support for Rails javascript post links (Mark Menard)
31
82
  * Upgrade selenium-client dependency to 1.2.14, and update for new waiting
32
83
  API (Balint Erdi)
@@ -37,7 +88,7 @@
37
88
  * Don't create a new instance of WWW::Mechanize for each request
38
89
  (Mark Menard)
39
90
  * Select fields with duplicate selected options sent an incorrect value (Noah Davis)
40
-
91
+
41
92
  == 0.4.3 / 2009-03-17
42
93
 
43
94
  * Minor enhancements
@@ -47,7 +98,7 @@
47
98
  * Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
48
99
  * When faced with a label with no for attribute, that contains a hidden field
49
100
  and another field, as can be the case in Rails 2.3's checkbox view,
50
- webrat now locates the non-hidden field. (Luke Melia)
101
+ webrat now locates the non-hidden field. (Luke Melia)
51
102
  * Add application_framework config for Selenium mode to determine how to
52
103
  start and stop the app server (Corey Donohoe)
53
104
 
@@ -63,7 +114,7 @@
63
114
  attributes in a hash and :count and :content options. See
64
115
  have_selector_spec.rb for more.
65
116
  * Add the same functionality mentioned above to have_xpath
66
-
117
+
67
118
  * Minor enhancements
68
119
 
69
120
  * Squeeze extra whitespace out of failures messages from contain
@@ -90,7 +141,7 @@
90
141
  redirected to (Adam Greene)
91
142
  * Recognize input tags with type button (Lena Herrmann)
92
143
  * Add uncheck method to Selenium mode (Lee Bankewitz)
93
-
144
+
94
145
  * Bug fixes
95
146
 
96
147
  * Make requests to a Rails app using a full URL instead of a relative path. This change
@@ -101,7 +152,7 @@
101
152
  to behave correctly (Noah Davis)
102
153
  * Switch to using selenium.click instead of .check when checking a checkbox
103
154
  (Noah Davis)
104
- * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
155
+ * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
105
156
  * Setup deprecated writers for the selenium_environment= and selenium_port= config
106
157
  * Ensure the previous pages params aren't passed through redirect (Daniel Lucraft and
107
158
  Bryan Helmkamp)
@@ -177,7 +228,7 @@
177
228
  * Added save_and_open_screengrab for Selenium mode (Luke Melia)
178
229
 
179
230
  * Bug fixes
180
-
231
+
181
232
  * field_labeled should disregard labels without matching fields (Kyle Hargraves)
182
233
  * Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
183
234
  [#105] (Zach Dennis)
data/Rakefile CHANGED
@@ -1,57 +1,41 @@
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
- require 'jeweler'
10
-
11
-
12
- ##############################################################################
13
- # Package && release
14
- ##############################################################################
15
- spec = Gem::Specification.new do |s|
16
- s.name = "webrat"
17
- s.version = Webrat::VERSION
18
- s.platform = Gem::Platform::RUBY
19
- s.author = "Bryan Helmkamp"
20
- s.email = "bryan" + "@" + "brynary.com"
21
- s.homepage = "http://github.com/brynary/webrat"
22
- s.summary = "Webrat. Ruby Acceptance Testing for Web applications"
23
- s.bindir = "bin"
24
- s.description = s.summary
25
- s.require_path = "lib"
26
- s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["vendor/**/*"]
27
-
28
- # rdoc
29
- s.has_rdoc = true
30
- s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
31
-
32
- # Dependencies
33
- s.add_dependency "nokogiri", ">= 1.2.0"
34
-
35
- s.rubyforge_project = "webrat"
36
- end
37
-
38
- Rake::GemPackageTask.new(spec) do |package|
39
- package.gem_spec = spec
40
- end
41
-
42
- Jeweler::Tasks.new(spec)
1
+ require "rubygems"
2
+
3
+ begin
4
+ require 'jeweler'
5
+
6
+ Jeweler::Tasks.new do |s|
7
+ s.name = "webrat"
8
+ s.author = "Bryan Helmkamp"
9
+ s.email = "bryan" + "@" + "brynary.com"
10
+ s.homepage = "http://github.com/brynary/webrat"
11
+ s.summary = "Ruby Acceptance Testing for Web applications"
12
+ s.description = <<-EOS.strip
13
+ Webrat lets you quickly write expressive and robust acceptance tests
14
+ for a Ruby web application. It supports simulating a browser inside
15
+ a Ruby process to avoid the performance hit and browser dependency of
16
+ Selenium or Watir, but the same API can also be used to drive real
17
+ Selenium tests when necessary (eg. for testing AJAX interactions).
18
+ Most Ruby web frameworks and testing frameworks are supported.
19
+ EOS
20
+
21
+ s.rubyforge_project = "webrat"
22
+ s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
23
+
24
+ # Dependencies
25
+ s.add_dependency "nokogiri", ">= 1.2.0"
26
+ s.add_dependency "rack", ">= 1.0"
27
+
28
+ # TODO: Add development dependencies
29
+ end
43
30
 
44
- desc 'Show information about the gem.'
45
- task :debug_gem do
46
- puts spec.to_ruby
31
+ Jeweler::RubyforgeTasks.new
32
+ rescue LoadError
33
+ puts "Jeweler not available. Install it with: gem install jeweler"
47
34
  end
48
35
 
49
- CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
50
-
51
- desc "Upload rdoc to brynary.com"
52
- task :publish_rdoc => :docs do
53
- sh "scp -r doc/ brynary.com:/apps/uploads/webrat"
54
- end
36
+ # require 'spec'
37
+ require 'spec/rake/spectask'
38
+ require 'spec/rake/verify_rcov'
55
39
 
56
40
  desc "Run API and Core specs"
57
41
  Spec::Rake::SpecTask.new do |t|
@@ -73,26 +57,47 @@ RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
73
57
  t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
74
58
  end
75
59
 
76
- desc 'Install the package as a gem.'
77
- task :install_gem => [:clean, :package] do
78
- gem_filename = Dir['pkg/*.gem'].first
79
- sh "sudo gem install --no-rdoc --no-ri --local #{gem_filename}"
80
- end
60
+ desc "Run everything against multiruby"
61
+ task :multiruby do
62
+ result = system "multiruby -S rake spec"
63
+ raise "Multiruby tests failed" unless result
64
+ result = system "jruby -S rake spec"
65
+ raise "JRuby tests failed" unless result
81
66
 
82
- desc "Delete generated RDoc"
83
- task :clobber_docs do
84
- FileUtils.rm_rf("doc")
85
- end
67
+ Dir.chdir "spec/integration/rails" do
68
+ result = system "multiruby -S rake test_unit:rails"
69
+ raise "Rails integration tests failed" unless result
86
70
 
87
- desc "Generate RDoc"
88
- task :docs => :clobber_docs do
89
- system "hanna --title 'Webrat #{Webrat::VERSION} API Documentation'"
90
- end
71
+ result = system "jruby -S rake test_unit:rails"
72
+ raise "Rails integration tests failed" unless result
73
+ end
91
74
 
92
- desc "Run specs using jruby"
93
- task "spec:jruby" do
94
- result = system "jruby -S rake spec"
95
- raise "JRuby tests failed" unless result
75
+ Dir.chdir "spec/integration/merb" do
76
+ result = system "multiruby -S rake spec"
77
+ raise "Merb integration tests failed" unless result
78
+
79
+ result = system "jruby -S rake spec"
80
+ raise "Rails integration tests failed" unless result
81
+ end
82
+
83
+ Dir.chdir "spec/integration/sinatra" do
84
+ result = system "multiruby -S rake test"
85
+ raise "Sinatra integration tests failed" unless result
86
+
87
+ result = system "jruby -S rake test"
88
+ raise "Sinatra integration tests failed" unless result
89
+ end
90
+
91
+ Dir.chdir "spec/integration/rack" do
92
+ result = system "multiruby -S rake test"
93
+ raise "Rack integration tests failed" unless result
94
+
95
+ result = system "jruby -S rake test"
96
+ raise "Rack integration tests failed" unless result
97
+ end
98
+
99
+ puts
100
+ puts "Multiruby OK!"
96
101
  end
97
102
 
98
103
  desc "Run each spec in isolation to test for dependency issues"
@@ -110,7 +115,7 @@ end
110
115
 
111
116
  namespace :spec do
112
117
  desc "Run the integration specs"
113
- task :integration => ["integration:rails", "integration:merb", "integration:sinatra", "integration:rack"]
118
+ task :integration => ["integration:rails", "integration:merb", "integration:sinatra", "integration:rack", "integration:mechanize"]
114
119
 
115
120
  namespace :integration do
116
121
  desc "Run the Rails integration specs"
@@ -147,7 +152,7 @@ namespace :spec do
147
152
  raise "Sinatra integration tests failed" unless result
148
153
  end
149
154
  end
150
-
155
+
151
156
  desc "Run the Sinatra integration specs"
152
157
  task :rack do
153
158
  Dir.chdir "spec/integration/rack" do
@@ -155,14 +160,24 @@ namespace :spec do
155
160
  raise "Rack integration tests failed" unless result
156
161
  end
157
162
  end
163
+
164
+ desc "Run the Mechanize integration specs"
165
+ task :mechanize do
166
+ Dir.chdir "spec/integration/mechanize" do
167
+ result = system "rake spec"
168
+ raise "Mechanize integration tests failed" unless result
169
+ end
170
+ end
158
171
  end
159
172
  end
160
173
 
161
- task :default => :spec
162
-
163
- task :precommit => ["spec", "spec:jruby", "spec:integration"]
164
-
165
174
  desc 'Removes trailing whitespace'
166
175
  task :whitespace do
167
176
  sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
168
- end
177
+ end
178
+
179
+ if defined?(Jeweler)
180
+ task :spec => :check_dependencies
181
+ end
182
+
183
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.1
data/lib/webrat.rb CHANGED
@@ -1,31 +1,16 @@
1
- require "rubygems"
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
5
+ autoload :MechanizeAdapter, "webrat/adapters/mechanize"
6
+ autoload :MerbAdapter, "webrat/adapters/merb"
7
+ autoload :RackAdapter, "webrat/adapters/rack"
8
+ autoload :RailsAdapter, "webrat/adapters/rails"
9
+ autoload :SinatraAdapter, "webrat/adapters/sinatra"
10
+
6
11
  # The common base class for all exceptions raised by Webrat.
7
12
  class WebratError < StandardError
8
13
  end
9
-
10
- VERSION = '0.4.4'
11
-
12
- def self.require_xml
13
- if on_java?
14
- gem "nokogiri", ">= 1.2.4"
15
- else
16
- gem "nokogiri", ">= 1.0.6"
17
- end
18
-
19
- require "nokogiri"
20
- require "webrat/core/xml/nokogiri"
21
- end
22
-
23
- def self.on_java?
24
- RUBY_PLATFORM =~ /java/
25
- end
26
-
27
14
  end
28
15
 
29
- Webrat.require_xml
30
-
31
16
  require "webrat/core"
@@ -1,11 +1,15 @@
1
1
  require "mechanize"
2
2
 
3
3
  module Webrat #:nodoc:
4
- class MechanizeSession < Session #:nodoc:
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