jferris-webrat 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/History.txt +306 -0
  2. data/MIT-LICENSE.txt +19 -0
  3. data/README.rdoc +85 -0
  4. data/Rakefile +158 -0
  5. data/install.rb +1 -0
  6. data/lib/webrat/core/configuration.rb +98 -0
  7. data/lib/webrat/core/elements/area.rb +31 -0
  8. data/lib/webrat/core/elements/element.rb +33 -0
  9. data/lib/webrat/core/elements/field.rb +403 -0
  10. data/lib/webrat/core/elements/form.rb +103 -0
  11. data/lib/webrat/core/elements/label.rb +31 -0
  12. data/lib/webrat/core/elements/link.rb +90 -0
  13. data/lib/webrat/core/elements/select_option.rb +35 -0
  14. data/lib/webrat/core/locators/area_locator.rb +38 -0
  15. data/lib/webrat/core/locators/button_locator.rb +54 -0
  16. data/lib/webrat/core/locators/field_by_id_locator.rb +37 -0
  17. data/lib/webrat/core/locators/field_labeled_locator.rb +56 -0
  18. data/lib/webrat/core/locators/field_locator.rb +25 -0
  19. data/lib/webrat/core/locators/field_named_locator.rb +41 -0
  20. data/lib/webrat/core/locators/form_locator.rb +19 -0
  21. data/lib/webrat/core/locators/label_locator.rb +34 -0
  22. data/lib/webrat/core/locators/link_locator.rb +66 -0
  23. data/lib/webrat/core/locators/locator.rb +20 -0
  24. data/lib/webrat/core/locators/select_option_locator.rb +59 -0
  25. data/lib/webrat/core/locators.rb +20 -0
  26. data/lib/webrat/core/logging.rb +21 -0
  27. data/lib/webrat/core/matchers/have_content.rb +73 -0
  28. data/lib/webrat/core/matchers/have_selector.rb +74 -0
  29. data/lib/webrat/core/matchers/have_tag.rb +21 -0
  30. data/lib/webrat/core/matchers/have_xpath.rb +147 -0
  31. data/lib/webrat/core/matchers.rb +4 -0
  32. data/lib/webrat/core/methods.rb +61 -0
  33. data/lib/webrat/core/mime.rb +29 -0
  34. data/lib/webrat/core/save_and_open_page.rb +50 -0
  35. data/lib/webrat/core/scope.rb +350 -0
  36. data/lib/webrat/core/session.rb +281 -0
  37. data/lib/webrat/core/xml/hpricot.rb +19 -0
  38. data/lib/webrat/core/xml/nokogiri.rb +76 -0
  39. data/lib/webrat/core/xml/rexml.rb +24 -0
  40. data/lib/webrat/core/xml.rb +115 -0
  41. data/lib/webrat/core.rb +14 -0
  42. data/lib/webrat/core_extensions/blank.rb +58 -0
  43. data/lib/webrat/core_extensions/deprecate.rb +8 -0
  44. data/lib/webrat/core_extensions/detect_mapped.rb +12 -0
  45. data/lib/webrat/core_extensions/meta_class.rb +6 -0
  46. data/lib/webrat/core_extensions/nil_to_param.rb +5 -0
  47. data/lib/webrat/mechanize.rb +74 -0
  48. data/lib/webrat/merb.rb +9 -0
  49. data/lib/webrat/merb_session.rb +65 -0
  50. data/lib/webrat/rack.rb +24 -0
  51. data/lib/webrat/rails.rb +105 -0
  52. data/lib/webrat/rspec-rails.rb +13 -0
  53. data/lib/webrat/selenium/location_strategy_javascript/button.js +12 -0
  54. data/lib/webrat/selenium/location_strategy_javascript/label.js +16 -0
  55. data/lib/webrat/selenium/location_strategy_javascript/webrat.js +5 -0
  56. data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +9 -0
  57. data/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js +15 -0
  58. data/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js +5 -0
  59. data/lib/webrat/selenium/matchers/have_content.rb +66 -0
  60. data/lib/webrat/selenium/matchers/have_selector.rb +49 -0
  61. data/lib/webrat/selenium/matchers/have_tag.rb +72 -0
  62. data/lib/webrat/selenium/matchers/have_xpath.rb +45 -0
  63. data/lib/webrat/selenium/matchers.rb +4 -0
  64. data/lib/webrat/selenium/selenium_extensions.js +6 -0
  65. data/lib/webrat/selenium/selenium_session.rb +247 -0
  66. data/lib/webrat/selenium.rb +154 -0
  67. data/lib/webrat/sinatra.rb +53 -0
  68. data/lib/webrat.rb +34 -0
  69. data/vendor/selenium-server.jar +0 -0
  70. metadata +141 -0
data/History.txt ADDED
@@ -0,0 +1,306 @@
1
+ == 0.4.3 / 2009-03-17
2
+
3
+ * Minor enhancements
4
+
5
+ * Support Rails 2.3. Use Rack::Utils to parse params (Matthew Ford)
6
+ * Support for "modular" Sinatra app style (Simon Rozet)
7
+ * Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
8
+ * When faced with a label with no for attribute, that contains a hidden field
9
+ and another field, as can be the case in Rails 2.3's checkbox view,
10
+ webrat now locates the non-hidden field. (Luke Melia)
11
+ * Add application_framework config for Selenium mode to determine how to
12
+ start and stop the app server (Corey Donohoe)
13
+
14
+ * Bug fixes
15
+
16
+ * Fix following of absolute redirect URL in Sinatra (Simon Rozet)
17
+
18
+ == 0.4.2 / 2009-02-24
19
+
20
+ * Major enhancements
21
+
22
+ * Significant improvements to have_selector. It now supports specifying
23
+ attributes in a hash and :count and :content options. See
24
+ have_selector_spec.rb for more.
25
+ * Add the same functionality mentioned above to have_xpath
26
+
27
+ * Minor enhancements
28
+
29
+ * Squeeze extra whitespace out of failures messages from contain
30
+ matcher
31
+ * Detect infinite redirects and raise a Webrat::InfiniteRedirectError
32
+ (Daniel Lucraft)
33
+
34
+ * Bug fixes
35
+
36
+ * Properly quote single and double quotes strings in XPath
37
+ * Fix warning caused by Nokogiri deprecating CSS::Parser.parse
38
+ (Aaron Patterson)
39
+ * Accept do/end blocks in matchers. [#157] (Peter Jaros)
40
+ * Quote --chdir option to mongrel_rails to support RAILS_ROOTs with spaces
41
+ (T.J. VanSlyke)
42
+
43
+ == 0.4.1 / 2009-01-31
44
+
45
+ * Minor enhancements
46
+
47
+ * Support Sinatra 0.9 (Harry Vangberg)
48
+ * Update query param parsing to work with latest Edge Rails
49
+ * Added #redirected_to method to easily check where an external redirect was
50
+ redirected to (Adam Greene)
51
+ * Recognize input tags with type button (Lena Herrmann)
52
+ * Add uncheck method to Selenium mode (Lee Bankewitz)
53
+
54
+ * Bug fixes
55
+
56
+ * Make requests to a Rails app using a full URL instead of a relative path. This change
57
+ is helpful for Rails apps that use subdomains. (John Hwang and Zach Dennis)
58
+ * Follow redirects that are on the same domain but a different subdomain
59
+ (Adam Greene)
60
+ * rescue from Webrat::TimeoutError in selenium matchers which allows NegativeMatchers
61
+ to behave correctly (Noah Davis)
62
+ * Switch to using selenium.click instead of .check when checking a checkbox
63
+ (Noah Davis)
64
+ * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
65
+ * Setup deprecated writers for the selenium_environment= and selenium_port= config
66
+ * Ensure the previous pages params aren't passed through redirect (Daniel Lucraft and
67
+ Bryan Helmkamp)
68
+ * Labels should only search for fields within the current scope (Kyle Hargraves)
69
+
70
+ == 0.4.0 / 2009-01-18
71
+
72
+ * _IMPORTANT_ Breaking change:
73
+
74
+ * Removed init.rb auto-require of webrat/rails
75
+ * Removed auto-require of webrat/rails when requiring webrat when RAILS_ENV is
76
+ defined
77
+
78
+ In your env.rb or test_helper.rb file, ensure you have something like:
79
+
80
+ require "webrat"
81
+
82
+ Webrat.configure do |config|
83
+ config.mode = :rails
84
+ end
85
+
86
+ * Major enhancements
87
+
88
+ * Major improvements to Webrat::Selenium (Many contributors listed here)
89
+ * Add assert_* methods for using Webrat's matchers w/o RSpec (Mike Gaffney, Amos King)
90
+ * Added Webrat.configure method for Webrat configuration [#33] (Mike Gaffney)
91
+ * Added select_time, select_date, and select_datetime to API. [#36] (Ben Mabey)
92
+ * Use Hpricot and REXML when not parsing with Nokogiri (on JRuby, for example)
93
+
94
+ * Minor enhancements
95
+
96
+ * Added Selenium grid configuration and support. (Amos King && Cornel Borcean)
97
+ * Support passing an ActiveRecord model to #within when in Rails mode [#68] (Luke Melia)
98
+ * Make assert_* matchers in rails mode increment the assertions count [#123] (Amos King)
99
+ * Added assert_* matchers to selenium matchers [#110] (Amos King)
100
+ * Added assert_contain, assert_not_contain [#86] (Mike Gaffney, Amos King)
101
+ * Add configuration options for the Selenium environment and port (Kieran Pilkington)
102
+ * Maximize the browser window after initializing Selenium (Luke Melia)
103
+ * Better inspect output for Webrat elements
104
+ * Sets the Webrat mode with Configuration#mode= in the config block [#85] (Mike Gaffney)
105
+ * Detect if the document is XML or HTML using the Content-Type when in Rails mode
106
+ * Expose #selenium method for direct access to Selenium client
107
+ * Check nokogiri gem version before requiring nokogiri
108
+ * Include the Selenium server jar file in the gem (Bryan Helmkamp, Ben Schwarz)
109
+ * Added key_down, key_up and fire_event to Selenium session (Fernando Garcia)
110
+ * Fix outputing README during Rails plugin install (Fernando Garcia)
111
+ * Strip newlines when matching label text (Miha Filej)
112
+ * Add simple support for accessing Webrat's matchers from RSpec by requiring
113
+ "webrat/rspec-rails" (David Chelimsky)
114
+ * Support save_and_open_page in Windows and Cygwin (Mike Gaffney)
115
+ * Added RadioField#checked? to indicated whether or not a radio button is checked
116
+ (Luke Melia)
117
+ * Add spec:jruby rake task for running Webrat's spec suite with JRuby
118
+ * Added field_by_xpath to locate a Webrat::Field using arbitrary XPath expressions
119
+ * Helpful error message for missing option values [#40] (Ben Mabey)
120
+ * Add set_hidden_field method (Noah Davis, Bryan Helmkamp)
121
+ * Add submit_form method for submitting a form by ID (Noah Davis, Bryan Helmkamp)
122
+ * Switch to using Nokogiri.parse for simple XML/XHTML autodetection [#66]
123
+ * Removed Webrat.root method, which seemed to be unused
124
+ * Added automatic starting and stopping of the Selenium server and a Mongrel Rails
125
+ app server when using webrat/selenium
126
+ * Switch to using selenium-client gem and vendor selenium-server.jar (Luke Melia)
127
+ * Added gemspec so the gem builds on GitHub now
128
+ * Deprecate old style methods (fills_in is deprecated in favor of fill_in, etc.)
129
+ * Improvements to the README and RDoc (Bryan Helmkamp, Mike Gaffney)
130
+ * Allow clicking links by id and id regexp (Mike Gaffney)
131
+ * Raise Webrat::DisabledFieldError when attempting to manipulate a disabled field
132
+ * Raise Webrat::NotFoundErrors when an element is not found
133
+ * Raise Webrat::PageLoadError when a failure occurs so that application exceptions
134
+ can be more accurately tested (Ryan Briones)
135
+ * Helpful error message for missing option in select box. [#40] (Ben Mabey)
136
+ * Extracted save_and_open page to make it usable in Selenium mode (Luke Melia)
137
+ * Added save_and_open_screengrab for Selenium mode (Luke Melia)
138
+
139
+ * Bug fixes
140
+
141
+ * field_labeled should disregard labels without matching fields (Kyle Hargraves)
142
+ * Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
143
+ [#105] (Zach Dennis)
144
+ * Support Rails > v2.2 by using ActionController::RequestParser for param parsing [#107]
145
+ (Marcello Nuccio)
146
+ * Raise a Webrat::NotFoundError if the scope passed to #within doesn't exist [#90]
147
+ * Match against link _text_ which decodes character references.
148
+ Useful for multibyte languages like Japanese (moronatural@gmail.com)
149
+ * Fix params hash generation for Mechanize when Merb is not defined [#62]
150
+ * Expose some Webrat methods that were missing from the Webrat::Methods module
151
+ (Low Chin Chau)
152
+ * Allow mechanize session to pass through basic auth (Ryan Briones)
153
+ * Improvements to the Mechanize support (Jeremy Burks)
154
+ * Fix following fully qualified local links (Lawrence Pit)
155
+ * Fixed bug where Webrat would lose complex parameters (like foo[bar[baz]][])
156
+ in Merb due to not correctly merging Mashes. (Drew Colthorp)
157
+ * Extend Rails' ActionController::IntegrationTest instead of
158
+ ActionController::Integration::Session (Fixes using Webrat's #select method and
159
+ avoids usage of method_missing)
160
+ * Ensure that Webrat::MechanizeSession.request_page always uses an absolute
161
+ URL. (Graham Ashton)
162
+ * Strip anchor tags from URIs before passing to Rails integration session
163
+ (Noah Davis)
164
+ * Treat text and regexp when matching Selenium buttons (Ross Kaffenberger)
165
+ * Allow SeleniumSession's click_button to be called without an argument without
166
+ blowing up (Luke Melia)
167
+
168
+ == 0.3.4 / 2008-12-29
169
+
170
+ * 1 Minor enhancement
171
+
172
+ * Fix compatibility with Nokogiri 1.1.0 on JRuby
173
+
174
+ * 1 Bug fix
175
+
176
+ * Correct version for Nokogiri dependency in gem
177
+
178
+ == 0.3.3 / 2008-12-28
179
+
180
+ * 1 Minor enhancement
181
+
182
+ * Fix compatibility with Nokogiri 1.1.0 on MRI
183
+
184
+ == 0.3.2 / 2008-11-08
185
+
186
+ * 1 Minor enhancement
187
+
188
+ * Fixes behavior or have_tag when a block is passed. It passes the matched node(s)
189
+ to the block for further specs again. (Carl Lerche)
190
+
191
+ == 0.3.1 / 2008-11-07
192
+
193
+ * 1 Minor enhancement
194
+
195
+ * Use @_webrat_session instance variable instead of @session for Merb integration
196
+ to avoid collisions
197
+
198
+ == 0.3.0 / 2008-11-07
199
+
200
+ * 4 Major enhancements
201
+
202
+ * Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman, Yehuda Katz)
203
+ * Added experimental Selenium support (Luke Melia)
204
+ * Add have_selector, have_xpath, have_tag and contain matchers from Merb
205
+ * Switch from Hpricot to Nokogiri for XML parsing (thanks, Aaron Patterson)
206
+
207
+ * 37 Minor enhancements
208
+
209
+ * Added #within for manipulating the current page within a selector scope
210
+ * Add support for file fields via #attaches_file method (Rails only at the moment)
211
+ (Kyle Hargraves)
212
+ * Add support for simulating SSL requests (Luke Melia)
213
+ * Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
214
+ * Added support for Sinatra and Rack (Aslak Hellesøy)
215
+ * Rename visits to visit, fills_in to fill_in, etc.
216
+ * Add #field_labeled for looking up form fields by label (David Chelimsky)
217
+ * Add #field_named and #field_with_id locators
218
+ * Don't depend on hoe anymore
219
+ * Return responses after sending requests
220
+ * Allow clicking links and buttons by a regular expression in Selenium (Luke Melia)
221
+ * Allow clicking links by a regular expression
222
+ * Add #http_accept for including MIME type HTTP "Accept" headers (Ryan Briones)
223
+ * Add #header to support inclusion of custom HTTP headers (Ryan Briones)
224
+ * Consider response codes 200-499 as successful enough to not raise a Webrat error
225
+ (David Leal)
226
+ * Add support for clicking areas of an image map (Alex Lang)
227
+ * Support relative links, including href="?foo=bar" (Kyle Hargraves)
228
+ * Separated Rails-specific code from the Webrat core to make it easier to use
229
+ Webrat with other environments
230
+ * Alias visits as visit, clicks_link as click_link, etc. for better readability
231
+ * Raise error when trying to interact with a disabled form element (Luke Melia)
232
+ * Don't send disabled form elements to the server (Nicholas A. Evans)
233
+ * Display response body when the page load is not successful (David Leal)
234
+ * CGI escape form field values (Miha Filej)
235
+ * Add support for redirect_to :back by sending HTTP_REFERER headers
236
+ (Hendrik Volkmer)
237
+ * Expose current DOM (as an Hpricot object) as #current_dom
238
+ * Add support for disabling JavaScript when clicking a link to enable testing of
239
+ both JS and non-JS implementations (Luke Melia and Bryan Helmkamp)
240
+ * Support &nbsp's as spaces in matching link text (Luke Melia)
241
+ * Support button elements (Nick Sieger)
242
+ * Support matching select options by regexp (Kyle Hargraves)
243
+ * save_and_open_page rewrites css and image references to provide a friendlier
244
+ debugging experience (Luke Melia)
245
+ * Added support for matching alt attributes in fields (primarly for clicks_button)
246
+ (Aaron Quint)
247
+ * Support '&' in submitted values (Kyle Hargraves)
248
+ * Support clicking links by title (Dan Barry)
249
+ * Added missing spec for clicking image buttons (Tim Harper)
250
+ * Switched tests to specs, and from Mocha to RSpec's mocking library
251
+ * Add support to click_button for IDs (Gwyn Morfey)
252
+ * Miscellaneous core refactorings (Jan Suchal)
253
+
254
+ * 8 Bug fixes
255
+
256
+ * Fix initialization of WWW::Mechanize (Derek Kastner)
257
+ * Don't open blank pages in the browser (Kyle Hargraves)
258
+ * Support radio buttons with multiple labels (Dan Barry)
259
+ * Fix load order bug on some platforms (Ismael Celis)
260
+ * Fix bug with empty select list option (Kyle Hargraves)
261
+ * Fix regression of not sending default values in password fields
262
+ * Don't explode if encountering inputs with no type attribute (assume text)
263
+ * Fix bug where choosing a radio button in a series with a default submitted the
264
+ incorrect field value (Luke Melia)
265
+
266
+ == 0.2.0 / 2008-04-04
267
+
268
+ * 4 Major enhancements
269
+
270
+ * Add save_and_open_page to aid in debugging
271
+ * Add radio button support via #chooses method
272
+ * Add basic support for Rails-generated JavaScript link tags
273
+ * Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
274
+ * Add support for textarea fields (Sacha Schlegel)
275
+
276
+ * 8 Minor enhancements
277
+
278
+ * Added reloads method to reload the page (Kamal Fariz Mahyuddi)
279
+ * Prevent making a request if clicking on local anchor link (Kamal Fariz Mahyuddi)
280
+ * Added clicks_link_within(selector, link_text), allowing restricting link search
281
+ to within a given css selector (Luke Melia)
282
+ * Allow specifying the input name/label when doing a select (David Chelimsky)
283
+ * Raise a specific exception if the developer tries to manipulate form elements
284
+ before loading a page (James Deville)
285
+ * Add support for alternate POST, PUT and DELETE link clicking (Kyle Hargraves)
286
+ * Change clicks_link to find the shortest matching link (Luke Melia)
287
+ * Improve matching for labels in potentially ambiguous cases
288
+
289
+ * 7 Bug fixes
290
+
291
+ * Fix incorrect serializing of collection inputs, i.e. name contains []
292
+ (Kamal Fariz Mahyuddi)
293
+ * Serialize empty text field values just like browsers (Kamal Fariz Mahyuddi)
294
+ * Quick fix to avoid @dom not initialized warnings (Kamal Fariz Mahyuddi)
295
+ * Docfix: bad reference to #select method in README (Luke Melia)
296
+ * Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden
297
+ input with the same name)
298
+ * Fix Edge Rails (a.k.a. 2.0 RC) compatibility (David Chelimsky)
299
+ * Support param hashes nested more than one level (David Chelimsky)
300
+
301
+ == 0.1.0 / 2007-11-28
302
+
303
+ * 1 major enhancement
304
+
305
+ * Birthday!
306
+
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,85 @@
1
+ = Webrat - Ruby Acceptance Testing for Web applications
2
+
3
+ - http://gitrdoc.com/brynary/webrat
4
+ - http://groups.google.com/group/webrat
5
+ - http://webrat.lighthouseapp.com/
6
+ - http://github.com/brynary/webrat
7
+ - #webrat on Freenode
8
+
9
+ == Description
10
+
11
+ Webrat lets you quickly write expressive and robust acceptance tests for a Ruby
12
+ web application.
13
+
14
+ == Features
15
+
16
+ * Browser Simulator for expressive, high level acceptance testing without the
17
+ performance hit and browser dependency of Selenium or Watir (See Webrat::Session)
18
+ * Use the same API for Browser Simulator and real Selenium tests using
19
+ Webrat::Selenium when necessary (eg. for testing AJAX interactions)
20
+ * Supports multiple Ruby web frameworks: Rails, Merb and Sinatra
21
+ * Supports popular test frameworks: RSpec, Cucumber, Test::Unit and Shoulda
22
+ * Webrat::Matchers API for verifying rendered HTML using CSS, XPath, etc.
23
+
24
+ == Example
25
+
26
+ class SignupTest < ActionController::IntegrationTest
27
+
28
+ def test_trial_account_sign_up
29
+ visit home_path
30
+ click_link "Sign up"
31
+ fill_in "Email", :with => "good@example.com"
32
+ select "Free account"
33
+ click_button "Register"
34
+ end
35
+
36
+ end
37
+
38
+ Behind the scenes, Webrat will ensure:
39
+
40
+ * If a link, form field or button is missing, the test will fail.
41
+ * If a URL is invalid, the test will fail.
42
+ * If a page load or form submission is unsuccessful, the test will fail.
43
+
44
+ == Installing Nokogiri
45
+
46
+ Users of Debian Linux (e.g. Ubuntu) need to run:
47
+
48
+ sudo apt-get install libxslt1-dev libxml2-dev.
49
+
50
+ Otherwise the Nokogiri gem, which Webrat depends on, won't install properly.
51
+
52
+ == Install for Rails
53
+
54
+ To install the latest release as a gem:
55
+
56
+ sudo gem install webrat
57
+
58
+ To install the latest code as a plugin: (_Note:_ This may be less stable than using a released version)
59
+
60
+ script/plugin install git://github.com/brynary/webrat.git
61
+
62
+ In your test_helper.rb or env.rb (for Cucumber) add:
63
+
64
+ require "webrat"
65
+
66
+ Webrat.configure do |config|
67
+ config.mode = :rails
68
+ end
69
+
70
+ == Install with Merb
71
+
72
+ Merb 1.0 has built-in, seamless Webrat support. Just start using
73
+ methods from Webrat::Session in your specs.
74
+
75
+ == Authors
76
+
77
+ - Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
78
+ - Original code written by {Seth Fitzsimmons}[mailto:seth@mojodna.net]
79
+ - Initial development was sponsored by EastMedia[http://www.eastmedia.com]
80
+ - Many other contributors. See attributions in History.txt
81
+
82
+ == License
83
+
84
+ Copyright (c) 2007-2008 Bryan Helmkamp, Seth Fitzsimmons.
85
+ See MIT-LICENSE.txt in this directory.
data/Rakefile ADDED
@@ -0,0 +1,158 @@
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
35
+
36
+ desc "Generate a gemspec file"
37
+ task :gemspec do
38
+ File.open("#{spec.name}.gemspec", 'w') do |f|
39
+ f.write spec.to_yaml
40
+ end
41
+ end
42
+
43
+ Rake::GemPackageTask.new(spec) do |package|
44
+ package.gem_spec = spec
45
+ end
46
+
47
+ desc 'Show information about the gem.'
48
+ task :debug_gem do
49
+ puts spec.to_ruby
50
+ end
51
+
52
+ CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
53
+
54
+ desc "Upload rdoc to brynary.com"
55
+ task :publish_rdoc => :docs do
56
+ sh "scp -r doc/ brynary.com:/apps/uploads/webrat"
57
+ end
58
+
59
+ desc "Run API and Core specs"
60
+ Spec::Rake::SpecTask.new 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
+ end
64
+
65
+ desc "Run all specs in spec directory with RCov"
66
+ Spec::Rake::SpecTask.new(:rcov) do |t|
67
+ t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
68
+ t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
69
+ t.rcov = true
70
+ t.rcov_opts = lambda do
71
+ IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
72
+ end
73
+ end
74
+
75
+ RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
76
+ t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
77
+ end
78
+
79
+ desc 'Install the package as a gem.'
80
+ task :install_gem => [:clean, :package] do
81
+ gem_filename = Dir['pkg/*.gem'].first
82
+ sh "sudo gem install --no-rdoc --no-ri --local #{gem_filename}"
83
+ end
84
+
85
+ desc "Delete generated RDoc"
86
+ task :clobber_docs do
87
+ FileUtils.rm_rf("doc")
88
+ end
89
+
90
+ desc "Generate RDoc"
91
+ task :docs => :clobber_docs do
92
+ system "hanna --title 'Webrat #{Webrat::VERSION} API Documentation'"
93
+ end
94
+
95
+ desc "Run specs using jruby"
96
+ task "spec:jruby" do
97
+ result = system "jruby -S rake spec"
98
+ raise "JRuby tests failed" unless result
99
+ end
100
+
101
+ desc "Run each spec in isolation to test for dependency issues"
102
+ task :spec_deps do
103
+ Dir["spec/**/*_spec.rb"].each do |test|
104
+ if !system("spec #{test} &> /dev/null")
105
+ puts "Dependency Issues: #{test}"
106
+ end
107
+ end
108
+ end
109
+
110
+ task :prepare do
111
+ system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat"
112
+ end
113
+
114
+ namespace :spec do
115
+ desc "Run the integration specs"
116
+ task :integration => ["integration:rails", "integration:merb", "integration:sinatra"]
117
+
118
+ namespace :integration do
119
+ desc "Run the Rails integration specs"
120
+ task :rails => ['rails:webrat'] #,'rails:selenium'] currently not running selenium as it doesn't pass.
121
+
122
+ namespace :rails do
123
+ task :selenium do
124
+ Dir.chdir "spec/integration/rails" do
125
+ result = system "rake test_unit:selenium"
126
+ raise "Rails integration tests failed" unless result
127
+ end
128
+ end
129
+
130
+ task :webrat do
131
+ Dir.chdir "spec/integration/rails" do
132
+ result = system "rake test_unit:rails"
133
+ raise "Rails integration tests failed" unless result
134
+ end
135
+ end
136
+ end
137
+
138
+ desc "Run the Merb integration specs"
139
+ task :merb do
140
+ Dir.chdir "spec/integration/merb" do
141
+ result = system "rake spec"
142
+ raise "Merb integration tests failed" unless result
143
+ end
144
+ end
145
+
146
+ desc "Run the Sinatra integration specs"
147
+ task :sinatra do
148
+ Dir.chdir "spec/integration/sinatra" do
149
+ result = system "rake test"
150
+ raise "Sinatra tntegration tests failed" unless result
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+ task :default => :spec
157
+
158
+ task :precommit => ["spec", "spec:jruby", "spec:integration"]
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ puts IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
@@ -0,0 +1,98 @@
1
+ require "webrat/core_extensions/deprecate"
2
+
3
+ module Webrat
4
+
5
+ # Configures Webrat. If this is not done, Webrat will be created
6
+ # with all of the default settings.
7
+ def self.configure(configuration = Webrat.configuration)
8
+ yield configuration if block_given?
9
+ @@configuration = configuration
10
+ end
11
+
12
+ def self.configuration # :nodoc:
13
+ @@configuration ||= Webrat::Configuration.new
14
+ end
15
+
16
+ # Webrat can be configured using the Webrat.configure method. For example:
17
+ #
18
+ # Webrat.configure do |config|
19
+ # config.parse_with_nokogiri = false
20
+ # end
21
+ class Configuration
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
+ # Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc.
27
+ attr_reader :mode # :nodoc:
28
+
29
+ # Save and open pages with error status codes (500-599) in a browser? Defualts to true.
30
+ attr_writer :open_error_files
31
+
32
+ # Which rails environment should the selenium tests be run in? Defaults to selenium.
33
+ attr_accessor :application_environment
34
+ webrat_deprecate :selenium_environment, :application_environment
35
+ webrat_deprecate :selenium_environment=, :application_environment=
36
+
37
+ # Which port is the application running on for selenium testing? Defaults to 3001.
38
+ attr_accessor :application_port
39
+ webrat_deprecate :selenium_port, :application_port
40
+ webrat_deprecate :selenium_port=, :application_port=
41
+
42
+ # Which underlying app framework we're testing with selenium
43
+ attr_accessor :application_framework
44
+
45
+ # Which server the application is running on for selenium testing? Defaults to localhost
46
+ attr_accessor :application_address
47
+
48
+ # Which server Selenium server is running on. Defaults to nil(server starts in webrat process and runs locally)
49
+ attr_accessor :selenium_server_address
50
+
51
+ # Which server Selenium port is running on. Defaults to 4444
52
+ attr_accessor :selenium_server_port
53
+
54
+ # Set the key that Selenium uses to determine the browser running. Default *firefox
55
+ attr_accessor :selenium_browser_key
56
+
57
+ # How many redirects to the same URL should be halted as an infinite redirect
58
+ # loop? Defaults to 10
59
+ attr_accessor :infinite_redirect_limit
60
+
61
+ def initialize # :nodoc:
62
+ self.open_error_files = true
63
+ self.parse_with_nokogiri = !Webrat.on_java?
64
+ self.application_environment = :selenium
65
+ self.application_port = 3001
66
+ self.application_address = 'localhost'
67
+ self.application_framework = 'rails'
68
+ self.selenium_server_port = 4444
69
+ self.infinite_redirect_limit = 10
70
+ self.selenium_browser_key = '*firefox'
71
+ end
72
+
73
+ def parse_with_nokogiri? #:nodoc:
74
+ @parse_with_nokogiri ? true : false
75
+ end
76
+
77
+ def open_error_files? #:nodoc:
78
+ @open_error_files ? true : false
79
+ end
80
+
81
+ # Allows setting of webrat's mode, valid modes are:
82
+ # :rails, :selenium, :rack, :sinatra, :mechanize, :merb
83
+ def mode=(mode)
84
+ @mode = mode.to_sym
85
+
86
+ # This is a temporary hack to support backwards compatibility
87
+ # with Merb 1.0.8 until it's updated to use the new Webrat.configure
88
+ # syntax
89
+ if @mode == :merb
90
+ require("webrat/merb_session")
91
+ else
92
+ require("webrat/#{mode}")
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ end