Permalink
Browse files

Import from subversion

  • Loading branch information...
0 parents commit a86f8ca56fc044656ac93a9fabbf88a8df5916bd @brynary brynary committed Mar 2, 2008
Showing with 1,387 additions and 0 deletions.
  1. +18 −0 CHANGELOG
  2. +19 −0 MIT-LICENSE
  3. +78 −0 README
  4. +26 −0 Rakefile
  5. +5 −0 TODO
  6. +3 −0 init.rb
  7. +1 −0 install.rb
  8. +2 −0 lib/webrat.rb
  9. +22 −0 lib/webrat/rails_extensions.rb
  10. +438 −0 lib/webrat/session.rb
  11. +121 −0 test/checks_test.rb
  12. +218 −0 test/clicks_button_test.rb
  13. +162 −0 test/clicks_link_test.rb
  14. +139 −0 test/fills_in_test.rb
  15. +17 −0 test/helper.rb
  16. +93 −0 test/selects_test.rb
  17. +25 −0 test/visits_test.rb
@@ -0,0 +1,18 @@
+== SVN
+
+* Allow specifying the input name/label when doing a select (Patch from David Chelimsky)
+* Raise a specific exception if the developer tries to manipulate form elements before loading a page (Patch from James Deville)
+* Add basic support for Rails-generated JavaScript link tags
+* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden input with the same name)
+* Add support for alternate POST, PUT and DELETE link clicking (Patch from Kyle Hargraves)
+* Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
+* Improve matching for labels in potentially ambiguous cases
+* Add support for textarea fields (Patch from Sacha Schlegel)
+* Fix Edge Rails (a.k.a. 2.0 RC) compatibility (Patch from David Chelimsky)
+* Support param hashes nested more than one level (Patch from David Chelimsky)
+
+== 0.1.0 / 2007-11-28
+
+* 1 major enhancement
+ * Birthday!
+
@@ -0,0 +1,19 @@
+Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,78 @@
+= Webrat - Ruby Acceptance Testing for Web applications
+
+by Bryan Helmkamp <bryan@brynary.com> and Seth Fitzsimmons <seth@mojodna.net>.
+
+Initial development sponsored by EastMedia (http://www.eastmedia.com).
+
+== DESCRIPTION:
+
+Webrat lets you quickly write robust and thorough acceptance tests for a Ruby
+web application. By leveraging the DOM, it can run tests similarly to an
+in-browser testing solution without the associated performance hit (and
+browser dependency). The result is tests that are less fragile and more
+effective at verifying that the app will respond properly to users.
+
+When comparing Webrat with an in-browser testing solution like Watir or
+Selenium, the primary consideration should be how much JavaScript the
+application uses. In-browser testing is currently the only way to test JS, and
+that may make it a requirement for your project. If JavaScript is not central
+to your application, Webrat is a simpler, effective solution that will let you
+run your tests much faster and more frequently. (Benchmarks forthcoming.)
+
+== SYNOPSIS:
+
+ def test_sign_up
+ visits "/"
+ clicks_link "Sign up"
+ fills_in "Email", :with => "good@example.com"
+ select "Free account"
+ clicks_button "Register"
+ ...
+ end
+
+Behind the scenes, this will perform the following work:
+
+1. Verify that loading the home page is successful
+2. Verify that a "Sign up" link exists on the home page
+3. Verify that loading the URL pointed to by the "Sign up" link leads to a
+ successful page
+4. Verify that there is an "Email" input field on the Sign Up page
+5. Verify that there is an select field on the Sign Up page with an option for
+ "Free account"
+6. Verify that there is a "Register" submit button on the page
+7. Verify that submitting the Sign Up form with the values "good@example.com"
+ and "Free account" leads to a successful page
+
+Take special note of the things _not_ specified in that test, that might cause
+tests to break unnecessarily as your application evolves:
+
+* The input field IDs or names (e.g. "user_email" or "user[email]"), which
+ could change if you rename a model
+* The ID of the form element (Webrat can do a good job of guessing, even if
+ there are multiple forms on the page.)
+* The URLs of links followed
+* The URL the form submission should be sent to, which could change if you
+ adjust your routes or controllers
+* The HTTP method for the login request
+
+A test written with Webrat can handle these changes smoothly.
+
+== REQUIREMENTS:
+
+* Rails >= 1.2.6
+* Hpricot >= 0.6
+* Rails integration tests in Test::Unit _or_
+* RSpec stories (using an RSpec version >= revision 2997)
+
+== INSTALL:
+
+ $ ruby script/plugin install http://svn.eastmedia.net/public/plugins/webrat/
+
+== HISTORY:
+
+See CHANGELOG in this directory.
+
+== LICENSE:
+
+Copyright (c) 2007 Bryan Helmkamp, Seth Fitzsimmons.
+See MIT-LICENSE in this directory.
@@ -0,0 +1,26 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the webrat plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate RDoc documentation for the Webrat plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Webrat'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+desc "Upload rdoc to brynary.com"
+task :publish_rdoc => :rdoc do
+ sh "scp -r rdoc/ brynary.com:/apps/uploads/webrat"
+end
@@ -0,0 +1,5 @@
+Option button support
+Full support for multiple forms on a page
+Track the current form based on the location of the last manipulated input, use this as a default for clicks_button
+Make current_url work with redirections
+Support for a hash mapping page names to page URLs
@@ -0,0 +1,3 @@
+if RAILS_ENV == "test"
+ require File.join(File.dirname(__FILE__), "lib", "webrat")
+end
@@ -0,0 +1 @@
+puts IO.read(File.join(File.dirname(__FILE__), 'README'))
@@ -0,0 +1,2 @@
+require File.join(File.dirname(__FILE__), "webrat", "rails_extensions")
+require File.join(File.dirname(__FILE__), "webrat", "session")
@@ -0,0 +1,22 @@
+module ActionController
+ module Integration
+
+ class Session
+ # Waiting for http://dev.rubyonrails.org/ticket/10497 to be committed.
+ def put_via_redirect(path, parameters = {}, headers = {})
+ put path, parameters, headers
+ follow_redirect! while redirect?
+ status
+ end
+
+ # Waiting for http://dev.rubyonrails.org/ticket/10497 to be committed.
+ def delete_via_redirect(path, parameters = {}, headers = {})
+ delete path, parameters, headers
+ follow_redirect! while redirect?
+ status
+ end
+
+ end
+
+ end
+end
Oops, something went wrong. Retry.

0 comments on commit a86f8ca

Please sign in to comment.