Skip to content

Commit

Permalink
Merge branch 'brynary/master'
Browse files Browse the repository at this point in the history
Conflicts:
	Manifest.txt
	README.txt
  • Loading branch information
dchelimsky committed Oct 22, 2008
2 parents a6b42ae + f831b49 commit bad6923
Show file tree
Hide file tree
Showing 47 changed files with 1,310 additions and 214 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,5 +1,6 @@
coverage
.DS_Store
pkg
doc
ri
email.txt
email.txt
77 changes: 46 additions & 31 deletions History.txt
Expand Up @@ -2,38 +2,53 @@

* Major enhancements

* Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman)
* Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
* Added support for Sinatra and Rack (Aslak Hellesøy)
* Added #within for manipulating the current page within a selector scope
* Add support for simulating SSL requests (Luke Melia)
* Add support for file fields via #attaches_file method (Patch from Kyle Hargraves)
* Support relative links, including href="?foo=bar" (Patch from Kyle Hargraves)
* 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)
* Add support for file fields via #attaches_file method (Kyle Hargraves)

* Minor enhancements

* Add support for redirect_to :back by sending HTTP_REFERER headers (Patch from Hendrik Volkmer)
* Add Webrat.root method for cross-framework support (Krzysztof Zylawy)
* Add #select_date for quickly filling out Rails-style date fields (Alex Lang)
* Support selecting options by their values (Alex Lang)
* Support for clicking areas of an image map (Alex Lang)
* Add should_see and should_not_see for verifying HTML response bodys
* 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
* 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)
* 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)
* Support &nbsp's as spaces in matching link text (Patch from Luke Melia)
* Support button elements (Patch from Nick Sieger)
* Support matching select options by regexp (Patch from Kyle Hargraves)
* 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) (Patch from Aaron Quint)
* Support '&' in submitted values (Patch from Kyle Hargraves)
* Support clicking links by title (Patch from Dan Barry)
* Added missing spec for clicking image buttons (Patch from Tim Harper)
* 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

* Don't open blank pages in the browser (Patch from Kyle Hargraves)
* Support radio buttons with multiple labels (Patch from Dan Barry)
* Fix load order bug on some platforms (Patch from Ismael Celis)
* Fix bug with empty select list option (Patch from Kyle Hargraves)
* Fix initialization of WWW::Mechanize (Derek Kastner)
* Don't open blank pages in the browser (Kyle Hargraves)
* Support radio buttons with multiple labels (Dan Barry)
* Fix load order bug on some platforms (Ismael Celis)
* 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)

== 0.2.0 / 2008-04-04

Expand All @@ -43,29 +58,29 @@
* Add radio button support via #chooses method
* Add basic support for Rails-generated JavaScript link tags
* Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
* Add support for textarea fields (Patch from Sacha Schlegel)
* Add support for textarea fields (Sacha Schlegel)

* 8 Minor enhancements

* Added reloads method to reload the page (Patch from Kamal Fariz Mahyuddi)
* Prevent making a request if clicking on local anchor link (Patch from Kamal Fariz Mahyuddi)
* 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 (Patch from Luke Melia)
* 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 support for alternate POST, PUT and DELETE link clicking (Patch from Kyle Hargraves)
* Change clicks_link to find the shortest matching link (Patch from 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)
* 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 [] (Patch from Kamal Fariz Mahyuddi)
* Serialize empty text field values just like browsers (Patch from Kamal Fariz Mahyuddi)
* Quick fix to avoid @dom not initialized warnings (Patch from Kamal Fariz Mahyuddi)
* Docfix: bad reference to #select method in README (Patch from Luke Melia)
* 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)
* 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)
* 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

Expand Down
29 changes: 29 additions & 0 deletions Manifest.txt
Expand Up @@ -8,6 +8,8 @@ init.rb
install.rb
lib/webrat.rb
lib/webrat/core.rb
lib/webrat/core/area.rb
lib/webrat/core/assertions.rb
lib/webrat/core/field.rb
lib/webrat/core/flunk.rb
lib/webrat/core/form.rb
Expand All @@ -19,21 +21,42 @@ lib/webrat/core/select_option.rb
lib/webrat/core/session.rb
lib/webrat/mechanize.rb
lib/webrat/mechanize/mechanize_session.rb
lib/webrat/merb.rb
lib/webrat/merb/indifferent_access.rb
lib/webrat/merb/param_parser.rb
lib/webrat/merb/support.rb
lib/webrat/merb/url_encoded_pair_parser.rb
lib/webrat/rack/rack_session.rb
lib/webrat/rails.rb
lib/webrat/rails/rails_session.rb
lib/webrat/rails/redirect_actions.rb
lib/webrat/rails/session.rb
lib/webrat/selenium.rb
lib/webrat/selenium/location_strategy_javascript/button.js
lib/webrat/selenium/location_strategy_javascript/label.js
lib/webrat/selenium/location_strategy_javascript/webrat.js
lib/webrat/selenium/location_strategy_javascript/webratlink.js
lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js
lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js
lib/webrat/selenium/selenium_session.rb
lib/webrat/sinatra/sinatra_session.rb
manifest.diff
mechanize_spike.rb
selenium_spike.rb
spec/api/attaches_file_spec.rb
spec/api/basic_auth_spec.rb
spec/api/checks_spec.rb
spec/api/chooses_spec.rb
spec/api/clicks_area_spec.rb
spec/api/clicks_button_spec.rb
spec/api/clicks_link_spec.rb
spec/api/fills_in_spec.rb
spec/api/reloads_spec.rb
spec/api/save_and_open_spec.rb
spec/api/selects_date_spec.rb
spec/api/selects_spec.rb
spec/api/should_not_see_spec.rb
spec/api/should_see_spec.rb
spec/api/visits_spec.rb
spec/api/within_spec.rb
spec/fakes/test_session.rb
Expand All @@ -42,4 +65,10 @@ spec/rcov.opts
spec/spec_helper.rb
spec/webrat/core/logging_spec.rb
spec/webrat/core/session_spec.rb
spec/webrat/mechanize/mechanize_session_spec.rb
spec/webrat/merb/helper.rb
spec/webrat/merb/indifferent_access_spec.rb
spec/webrat/merb/session_spec.rb
spec/webrat/rails/helper.rb
spec/webrat/rails/rails_session_spec.rb
webrat.gemspec
7 changes: 7 additions & 0 deletions README.txt
Expand Up @@ -59,6 +59,13 @@ tests to break unnecessarily as your application evolves:

A test written with Webrat can handle these changes to these without any modifications.

=== Merb
To avoid losing sessions, you need this in environments/test.rb:

Merb::Config.use do |c|
c[:session_store] = 'memory'
end

=== Install

To install the latest release:
Expand Down
17 changes: 14 additions & 3 deletions Rakefile
Expand Up @@ -35,28 +35,39 @@ def remove_task(task_name)
Rake.application.remove_task(task_name)
end

def set_file_list
if ENV['TEST_MODE'] == "merb"
list = FileList['spec/**/*_spec.rb']
list = list.find_all do |file| !file.match("rails") end
return list
else
return FileList['spec/**/*_spec.rb']
end
end

remove_task "test"
remove_task "test_deps"

desc "Run all specs in spec directory"
Spec::Rake::SpecTask.new do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_files = set_file_list
end

desc "Run all specs in spec directory with RCov"
Spec::Rake::SpecTask.new(:rcov) do |t|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_files = set_file_list
t.rcov = true
t.rcov_opts = lambda do
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
end
end


require 'spec/rake/verify_rcov'
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
t.threshold = 97.1 # Make sure you have rcov 0.7 or higher!
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
end

remove_task "default"
Expand Down
2 changes: 1 addition & 1 deletion init.rb
@@ -1,3 +1,3 @@
if RAILS_ENV == "test"
if RAILS_ENV == "test" || RAILS_ENV == "selenium"
require File.join(File.dirname(__FILE__), "lib", "webrat")
end
7 changes: 5 additions & 2 deletions lib/webrat.rb
@@ -1,9 +1,12 @@
module Webrat
VERSION = '0.2.1'
VERSION = '0.2.2'
def self.root
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
end
end

require "rubygems"
require "active_support"

require File.dirname(__FILE__) + "/webrat/core"
require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV)
require File.dirname(__FILE__) + "/webrat/merb" if defined?(Merb)
44 changes: 44 additions & 0 deletions lib/webrat/core/area.rb
@@ -0,0 +1,44 @@
module Webrat
class Area

def initialize(session, element)
@session = session
@element = element
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

def href
@element["href"]
end

def title
@element["title"]
end

def id
@element["id"]
end


def absolute_href
if href =~ /^\?/
"#{@session.current_url}#{href}"
elsif href !~ %r{^https?://[\w|.]+(/.*)} && (href !~ /^\//)
"#{@session.current_url}/#{href}"
else
href
end
end

end
end
27 changes: 27 additions & 0 deletions lib/webrat/core/assertions.rb
@@ -0,0 +1,27 @@
module Webrat
module Assertions

def should_see(text_or_regexp)
case text_or_regexp
when Regexp
return if scoped_html.match(text_or_regexp)
else
return if scoped_html.include?(text_or_regexp)
end

flunk("Should see #{text_or_regexp.inspect} but didn't")
end

def should_not_see(text_or_regexp)
case text_or_regexp
when Regexp
return unless scoped_html.match(text_or_regexp)
else
return unless scoped_html.include?(text_or_regexp)
end

flunk("Should not see #{text_or_regexp.inspect} but did")
end

end
end

0 comments on commit bad6923

Please sign in to comment.