Skip to content

Commit

Permalink
Import from subversion
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Mar 2, 2008
0 parents commit a86f8ca
Show file tree
Hide file tree
Showing 17 changed files with 1,387 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG
@@ -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!

19 changes: 19 additions & 0 deletions MIT-LICENSE
@@ -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.
78 changes: 78 additions & 0 deletions README
@@ -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.
26 changes: 26 additions & 0 deletions Rakefile
@@ -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
5 changes: 5 additions & 0 deletions TODO
@@ -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
3 changes: 3 additions & 0 deletions init.rb
@@ -0,0 +1,3 @@
if RAILS_ENV == "test"
require File.join(File.dirname(__FILE__), "lib", "webrat")
end
1 change: 1 addition & 0 deletions install.rb
@@ -0,0 +1 @@
puts IO.read(File.join(File.dirname(__FILE__), 'README'))
2 changes: 2 additions & 0 deletions lib/webrat.rb
@@ -0,0 +1,2 @@
require File.join(File.dirname(__FILE__), "webrat", "rails_extensions")
require File.join(File.dirname(__FILE__), "webrat", "session")
22 changes: 22 additions & 0 deletions lib/webrat/rails_extensions.rb
@@ -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

0 comments on commit a86f8ca

Please sign in to comment.