Skip to content

Commit

Permalink
merging in current codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
gaffo committed Dec 9, 2008
2 parents 28f2898 + 2d427ed commit 24ad539
Show file tree
Hide file tree
Showing 70 changed files with 1,942 additions and 762 deletions.
122 changes: 96 additions & 26 deletions History.txt
@@ -1,40 +1,100 @@
== Trunk
== Trunk (Git)

* _IMPORTANT_ Breaking change:

* Removed init.rb auto-require of webrat/rails
* Removed auto-require of webrat/rails when requiring webrat when RAILS_ENV is
defined

In your env.rb file, ensure you have:

require "webrat/rails"

* Major enhancements

* Added selects_time, selects_date, and selects_datetime to API. (Ben Mabey, Ticket #36)
* Added select_time, select_date, and select_datetime to API. [#36] (Ben Mabey)
* Use Hpricot and REXML when not parsing with Nokogiri (on JRuby, for example)

* Minor enhancements
* Now sets the mode with configuration.mode in the block (gaffo, Ticket #85)
* Allow clicking links by id and id regexp (gaffo)
* Raise Webrat::PageLoadError when a failure occurs so that application exceptions can be more accurately tested (Ryan Briones)
* Helpful error message for missing option in select box. (Ben Mabey, Ticket #40)
* Now sets the mode with configuration.mode in the block (Mike Gaffney, Ticket #85)
* Detect if the document is XML or HTML using the Content-Type when in Rails mode
* Expose #selenium method for direct access to Selenium client
* Check nokogiri gem version before requiring nokogiri
* Include the Selenium server jar file in the gem (Bryan Helmkamp, Ben Schwarz)
* Added key_down, key_up and fire_event to Selenium session (Fernando Garcia)
* Fix outputing README during Rails plugin install (Fernando Garcia)
* Strip newlines when matching label text (Miha Filej)
* Add simple support for accessing Webrat's matchers from RSpec by requiring
"webrat/rspec-rails" (David Chelimsky)
* Support save_and_open_page in Windows and Cygwin (Mike Gaffney)
* Added RadioField#checked? to indicated whether or not a radio button is checked
(Luke Melia)
* Add spec:jruby rake task for running Webrat's spec suite with JRuby
* Added field_by_xpath to locate a Webrat::Field using arbitrary XPath expressions
* Helpful error message for missing option values [#40] (Ben Mabey)
* Add set_hidden_field method (Noah Davis, Bryan Helmkamp)
* Add submit_form method for submitting a form by ID (Noah Davis, Bryan Helmkamp)
* Switch to using Nokogiri.parse for simple XML/XHTML autodetection [#66]
* Removed Webrat.root method, which seemed to be unused
* Added Webrat.configure method for global Webrat configuration [#33]
(Mike Gaffney)
* Added automatic starting and stopping of the Selenium server and a Mongrel Rails
app server when using webrat/selenium
* Switch to using selenium-client gem and vendor selenium-server.jar (Luke Melia)
* Added gemspec so the gem builds on GitHub now
* Deprecate old style methods (fills_in is deprecated in favor of fill_in, etc.)
* Improcements to the README and RDoc (Bryan Helmkamp, Mike Gaffney)
* Allow clicking links by id and id regexp (Mike Gaffney)
* Raise Webrat::DisabledFieldError when attempting to manipulate a disabled field
* Raise Webrat::NotFoundErrors when an element is not found
* Raise Webrat::PageLoadError when a failure occurs so that application exceptions
can be more accurately tested (Ryan Briones)
* Helpful error message for missing option in select box. [#40] (Ben Mabey)

* Bug fixes

* Match against link _text_ which decodes character references.
Useful for multibyte languages like Japanese (moronatural@gmail.com)
* Fix params hash generation for Mechanize when Merb is not defined [#62]
* Expose some Webrat methods that were missing from the Webrat::Methods module
(Low Chin Chau)
* Allow mechanize session to pass through basic auth (Ryan Briones)
* Improvements to the Mechanize support (Jeremy Burks)
* Fix following fully qualified local links (Lawrence Pit)
* Fixed bug where Webrat would lose complex parameters (like foo[bar[baz]][])
in Merb due to not correctly merging Mashes. (Drew Colthorp)
* Extend Rails' ActionController::IntegrationTest instead of
ActionController::Integration::Session (Fixes using Webrat's #select method and
avoids usage of method_missing)

== 0.3.2 / 2008-11-08

* Minor enhancements
* 1 Minor enhancement

* Fixes behavior or have_tag when a block is passed. It passes the matched node(s) to the block for further specs again. (Carl Lerche)
* Fixes behavior or have_tag when a block is passed. It passes the matched node(s)
to the block for further specs again. (Carl Lerche)

== 0.3.1 / 2008-11-07

* Minor enhancements
* 1 Minor enhancement

* Use @_webrat_session instance variable instead of @session for Merb integration to avoid collisions
* Use @_webrat_session instance variable instead of @session for Merb integration
to avoid collisions

== 0.3.0 / 2008-11-07

* Major enhancements
* 4 Major enhancements

* Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman, Yehuda Katz)
* Added experimental Selenium support (Luke Melia)
* Add have_selector, have_xpath, have_tag and contain matchers from Merb
* Switch from Hpricot to Nokogiri for XML parsing (thanks, Aaron Patterson)

* Minor enhancements
* 37 Minor enhancements

* Added #within for manipulating the current page within a selector scope
* Add support for file fields via #attaches_file method (Rails only at the moment) (Kyle Hargraves)
* Add support for file fields via #attaches_file method (Rails only at the moment)
(Kyle Hargraves)
* Add support for simulating SSL requests (Luke Melia)
* Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
* Added support for Sinatra and Rack (Aslak Hellesøy)
Expand All @@ -47,32 +107,37 @@
* Allow clicking links by a regular expression
* Add #http_accept for including MIME type HTTP "Accept" headers (Ryan Briones)
* Add #header to support inclusion of custom HTTP headers (Ryan Briones)
* Consider response codes 200-499 as successful enough to not raise a Webrat error (David Leal)
* Consider response codes 200-499 as successful enough to not raise a Webrat error
(David Leal)
* Add support for clicking areas of an image map (Alex Lang)
* Support relative links, including href="?foo=bar" (Kyle Hargraves)
* Separated Rails-specific code from the Webrat core to make it easier to use Webrat with other environments
* Separated Rails-specific code from the Webrat core to make it easier to use
Webrat with other environments
* Alias visits as visit, clicks_link as click_link, etc. for better readability
* Raise error when trying to interact with a disabled form element (Luke Melia)
* Don't send disabled form elements to the server (Nicholas A. Evans)
* Display response body when the page load is not successful (David Leal)
* CGI escape form field values (Miha Filej)
* Add support for redirect_to :back by sending HTTP_REFERER headers (Hendrik Volkmer)
* Add support for redirect_to :back by sending HTTP_REFERER headers
(Hendrik Volkmer)
* Expose current DOM (as an Hpricot object) as #current_dom
* Add support for disabling JavaScript when clicking a link to enable testing of both JS
and non-JS implementations (Luke Melia and Bryan Helmkamp)
* Add support for disabling JavaScript when clicking a link to enable testing of
both JS and non-JS implementations (Luke Melia and Bryan Helmkamp)
* Support &nbsp's as spaces in matching link text (Luke Melia)
* Support button elements (Nick Sieger)
* Support matching select options by regexp (Kyle Hargraves)
* save_and_open_page rewrites css and image references to provide a friendlier debugging experience (Luke Melia)
* Added support for matching alt attributes in fields (primarly for clicks_button) (Aaron Quint)
* save_and_open_page rewrites css and image references to provide a friendlier
debugging experience (Luke Melia)
* Added support for matching alt attributes in fields (primarly for clicks_button)
(Aaron Quint)
* Support '&' in submitted values (Kyle Hargraves)
* Support clicking links by title (Dan Barry)
* Added missing spec for clicking image buttons (Tim Harper)
* Switched tests to specs, and from Mocha to RSpec's mocking library
* Add support to click_button for IDs (Gwyn Morfey)
* Miscellaneous core refactorings (Jan Suchal)

* Bug fixes
* 8 Bug fixes

* Fix initialization of WWW::Mechanize (Derek Kastner)
* Don't open blank pages in the browser (Kyle Hargraves)
Expand All @@ -81,7 +146,8 @@
* Fix bug with empty select list option (Kyle Hargraves)
* Fix regression of not sending default values in password fields
* Don't explode if encountering inputs with no type attribute (assume text)
* Fix bug where choosing a radio button in a series with a default submitted the incorrect field value (Luke Melia)
* Fix bug where choosing a radio button in a series with a default submitted the
incorrect field value (Luke Melia)

== 0.2.0 / 2008-04-04

Expand All @@ -98,25 +164,29 @@
* Added reloads method to reload the page (Kamal Fariz Mahyuddi)
* Prevent making a request if clicking on local anchor link (Kamal Fariz Mahyuddi)
* Added clicks_link_within(selector, link_text), allowing restricting link search
to within a given css selector (Luke Melia)
to within a given css selector (Luke Melia)
* Allow specifying the input name/label when doing a select (David Chelimsky)
* Raise a specific exception if the developer tries to manipulate form elements before loading a page (James Deville)
* Raise a specific exception if the developer tries to manipulate form elements
before loading a page (James Deville)
* Add support for alternate POST, PUT and DELETE link clicking (Kyle Hargraves)
* Change clicks_link to find the shortest matching link (Luke Melia)
* Improve matching for labels in potentially ambiguous cases

* 7 Bug fixes

* Fix incorrect serializing of collection inputs, i.e. name contains [] (Kamal Fariz Mahyuddi)
* Fix incorrect serializing of collection inputs, i.e. name contains []
(Kamal Fariz Mahyuddi)
* Serialize empty text field values just like browsers (Kamal Fariz Mahyuddi)
* Quick fix to avoid @dom not initialized warnings (Kamal Fariz Mahyuddi)
* Docfix: bad reference to #select method in README (Luke Melia)
* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden input with the same name)
* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden
input with the same name)
* Fix Edge Rails (a.k.a. 2.0 RC) compatibility (David Chelimsky)
* Support param hashes nested more than one level (David Chelimsky)

== 0.1.0 / 2007-11-28

* 1 major enhancement

* Birthday!

11 changes: 10 additions & 1 deletion README.rdoc
Expand Up @@ -4,6 +4,7 @@
- http://groups.google.com/group/webrat
- http://webrat.lighthouseapp.com/
- http://github.com/brynary/webrat
- #webrat on Freenode

== Description

Expand All @@ -15,7 +16,7 @@ web application.
* Browser Simulator for expressive, high level acceptance testing without the
performance hit and browser dependency of Selenium or Watir (See Webrat::Session)
* Use the same API for Browser Simulator and real Selenium tests using
Webrat::SeleniumSession when necessary (eg. for testing AJAX interactions)
Webrat::Selenium when necessary (eg. for testing AJAX interactions)
* Supports multiple Ruby web frameworks: Rails, Merb and Sinatra
* Supports popular test frameworks: RSpec, Cucumber, Test::Unit and Shoulda
* Webrat::Matchers API for verifying rendered HTML using CSS, XPath, etc.
Expand All @@ -40,6 +41,14 @@ Behind the scenes, Webrat will ensure:
* If a URL is invalid, the test will fail.
* If a page load or form submission is unsuccessful, the test will fail.

== Installing Nokogiri

Users of Debian Linux (e.g. Ubuntu) need to run:

sudo apt-get install libxslt1-dev libxml2-dev.

Otherwise the Nokogiri gem, which Webrat depends on, won't install properly.

== Install for Rails

To install the latest release as a gem:
Expand Down
24 changes: 20 additions & 4 deletions Rakefile
Expand Up @@ -21,14 +21,14 @@ spec = Gem::Specification.new do |s|
s.bindir = "bin"
s.description = s.summary
s.require_path = "lib"
s.files = %w(History.txt init.rb install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"]
s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["vendor/**/*"]

# rdoc
s.has_rdoc = true
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)

# Dependencies
s.add_dependency "nokogiri", ">= 1.0.3"
s.add_dependency "nokogiri", ">= 1.0.6"

s.rubyforge_project = "webrat"
end
Expand Down Expand Up @@ -75,8 +75,13 @@ task :install_gem => [:clean, :package] do
sh "sudo gem install --local #{gem}"
end

desc "Delete generated RDoc"
task :clobber_docs do
FileUtils.rm_rf("doc")
end

desc "Generate RDoc"
task :docs do
task :docs => :clobber_docs do
system "hanna --title 'Webrat #{Webrat::VERSION} API Documentation'"
end

Expand All @@ -85,4 +90,15 @@ task "spec:jruby" do
system "jruby -S rake spec"
end

task :default => :spec
desc "Run each spec in isolation to test for dependency issues"
task :spec_deps do
Dir["spec/**/*_spec.rb"].each do |test|
if !system("spec #{test} &> /dev/null")
puts "Dependency Issues: #{test}"
end
end
end

task :default => :spec

task :precommit => ["spec", "spec:jruby"]
3 changes: 0 additions & 3 deletions init.rb

This file was deleted.

4 changes: 3 additions & 1 deletion lib/webrat.rb
Expand Up @@ -10,14 +10,16 @@ class WebratError < StandardError
VERSION = '0.3.2.1'

def self.require_xml
gem "nokogiri", ">= 1.0.6"

if on_java?
# We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
require "nokogiri/css"
require "hpricot"
require "rexml/document"
else
require "nokogiri"
require "webrat/core/nokogiri"
require "webrat/core/xml/nokogiri"
end
end

Expand Down
12 changes: 6 additions & 6 deletions lib/webrat/core.rb
@@ -1,13 +1,13 @@
require "webrat/core/configuration"
require "webrat/core/xml"
require "webrat/core/nokogiri"
require "webrat/core/xml/nokogiri"
require "webrat/core/logging"
require "webrat/core/form"
require "webrat/core/elements/form"
require "webrat/core/scope"
require "webrat/core/link"
require "webrat/core/area"
require "webrat/core/label"
require "webrat/core/select_option"
require "webrat/core/elements/link"
require "webrat/core/elements/area"
require "webrat/core/elements/label"
require "webrat/core/elements/select_option"
require "webrat/core/session"
require "webrat/core/methods"
require "webrat/core/matchers"
11 changes: 8 additions & 3 deletions lib/webrat/core/configuration.rb
Expand Up @@ -7,10 +7,15 @@ def self.configure(configuration = Webrat::Configuration.new)
@@configuration = configuration
end

def self.configuration
def self.configuration # :nodoc:
@@configuration ||= Webrat::Configuration.new
end


# Webrat can be configured using the Webrat.configure method. For example:
#
# Webrat.configure do |config|
# config.parse_with_nokogiri = false
# end
class Configuration

RAILS_MODE = :rails
Expand All @@ -24,7 +29,7 @@ class Configuration
attr_writer :parse_with_nokogiri

# Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc.
attr_accessor :mode
attr_accessor :mode # :nodoc:

# Save and open pages with error status codes (500-599) in a browser? Defualts to true.
attr_writer :open_error_files
Expand Down
27 changes: 7 additions & 20 deletions lib/webrat/core/area.rb → lib/webrat/core/elements/area.rb
@@ -1,34 +1,21 @@
require "webrat/core/elements/element"

module Webrat
class Area #:nodoc:
class Area < Element #:nodoc:

def initialize(session, element)
@session = session
@element = element
def self.xpath_search
".//area"
end

def click(method = nil, options = {})
@session.request_page(absolute_href, :get, {})
end

def matches_text?(id_or_title)
matcher = /#{Regexp.escape(id_or_title.to_s)}/i
title =~ matcher || id =~ matcher
end

protected
protected

def href
@element["href"]
end

def title
@element["title"]
Webrat::XML.attribute(@element, "href")
end

def id
@element["id"]
end


def absolute_href
if href =~ /^\?/
Expand Down

0 comments on commit 24ad539

Please sign in to comment.