benschwarz-webrat 0.3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +184 -0
- data/MIT-LICENSE.txt +19 -0
- data/README.rdoc +81 -0
- data/Rakefile +104 -0
- data/install.rb +1 -0
- data/lib/webrat.rb +34 -0
- data/lib/webrat/core.rb +13 -0
- data/lib/webrat/core/configuration.rb +44 -0
- data/lib/webrat/core/elements/area.rb +31 -0
- data/lib/webrat/core/elements/element.rb +29 -0
- data/lib/webrat/core/elements/field.rb +386 -0
- data/lib/webrat/core/elements/form.rb +103 -0
- data/lib/webrat/core/elements/label.rb +31 -0
- data/lib/webrat/core/elements/link.rb +94 -0
- data/lib/webrat/core/elements/select_option.rb +35 -0
- data/lib/webrat/core/locators.rb +20 -0
- data/lib/webrat/core/locators/area_locator.rb +38 -0
- data/lib/webrat/core/locators/button_locator.rb +54 -0
- data/lib/webrat/core/locators/field_by_id_locator.rb +37 -0
- data/lib/webrat/core/locators/field_labeled_locator.rb +50 -0
- data/lib/webrat/core/locators/field_locator.rb +25 -0
- data/lib/webrat/core/locators/field_named_locator.rb +41 -0
- data/lib/webrat/core/locators/form_locator.rb +19 -0
- data/lib/webrat/core/locators/label_locator.rb +34 -0
- data/lib/webrat/core/locators/link_locator.rb +66 -0
- data/lib/webrat/core/locators/locator.rb +20 -0
- data/lib/webrat/core/locators/select_option_locator.rb +59 -0
- data/lib/webrat/core/logging.rb +21 -0
- data/lib/webrat/core/matchers.rb +4 -0
- data/lib/webrat/core/matchers/have_content.rb +55 -0
- data/lib/webrat/core/matchers/have_selector.rb +37 -0
- data/lib/webrat/core/matchers/have_tag.rb +57 -0
- data/lib/webrat/core/matchers/have_xpath.rb +83 -0
- data/lib/webrat/core/methods.rb +54 -0
- data/lib/webrat/core/mime.rb +29 -0
- data/lib/webrat/core/scope.rb +318 -0
- data/lib/webrat/core/session.rb +241 -0
- data/lib/webrat/core/xml.rb +99 -0
- data/lib/webrat/core/xml/hpricot.rb +19 -0
- data/lib/webrat/core/xml/nokogiri.rb +44 -0
- data/lib/webrat/core/xml/rexml.rb +24 -0
- data/lib/webrat/core_extensions/blank.rb +58 -0
- data/lib/webrat/core_extensions/deprecate.rb +8 -0
- data/lib/webrat/core_extensions/detect_mapped.rb +12 -0
- data/lib/webrat/core_extensions/hash_with_indifferent_access.rb +131 -0
- data/lib/webrat/core_extensions/meta_class.rb +6 -0
- data/lib/webrat/core_extensions/nil_to_param.rb +5 -0
- data/lib/webrat/mechanize.rb +43 -0
- data/lib/webrat/merb.rb +77 -0
- data/lib/webrat/rack.rb +26 -0
- data/lib/webrat/rails.rb +88 -0
- data/lib/webrat/rails/redirect_actions.rb +18 -0
- data/lib/webrat/rspec-rails.rb +13 -0
- data/lib/webrat/selenium.rb +58 -0
- data/lib/webrat/selenium/location_strategy_javascript/button.js +12 -0
- data/lib/webrat/selenium/location_strategy_javascript/label.js +16 -0
- data/lib/webrat/selenium/location_strategy_javascript/webrat.js +5 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +9 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js +15 -0
- data/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js +5 -0
- data/lib/webrat/selenium/selenium_extensions.js +6 -0
- data/lib/webrat/selenium/selenium_session.rb +186 -0
- data/lib/webrat/sinatra.rb +21 -0
- data/vendor/selenium-server.jar +0 -0
- metadata +144 -0
data/History.txt
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
== Trunk
|
2
|
+
|
3
|
+
TODO: Document changes to Webrat requiring. See:
|
4
|
+
|
5
|
+
54de30032e7a6be5ef0321a3fcab318029dad0f8
|
6
|
+
ad8956070788cf3fa0f2ea5cbcb33867028c8605
|
7
|
+
|
8
|
+
* Major enhancements
|
9
|
+
|
10
|
+
* Use Hpricot and REXML when not parsing with Nokogiri (on JRuby, for example)
|
11
|
+
* Added select_time, select_date, and select_datetime to API. [#36] (Ben Mabey)
|
12
|
+
|
13
|
+
* Minor enhancements
|
14
|
+
|
15
|
+
* Include the Selenium server jar file in the gem (Bryan Helmkamp, Ben Schwarz)
|
16
|
+
* Added key_down, key_up and fire_event to Selenium session (Fernando Garcia)
|
17
|
+
* Fix outputing README during Rails plugin install (Fernando Garcia)
|
18
|
+
* Strip newlines when matching label text (Miha Filej)
|
19
|
+
* Add simple support for accessing Webrat's matchers from RSpec by requiring
|
20
|
+
"webrat/rspec-rails" (David Chelimsky)
|
21
|
+
* Support save_and_open_page in Windows and Cygwin (Mike Gaffney)
|
22
|
+
* Added RadioField#checked? to indicated whether or not a radio button is checked
|
23
|
+
(Luke Melia)
|
24
|
+
* Add spec:jruby rake task for running Webrat's spec suite with JRuby
|
25
|
+
* Added field_by_xpath to locate a Webrat::Field using arbitrary XPath expressions
|
26
|
+
* Helpful error message for missing option values [#40] (Ben Mabey)
|
27
|
+
* Add set_hidden_field method (Noah Davis, Bryan Helmkamp)
|
28
|
+
* Add submit_form method for submitting a form by ID (Noah Davis, Bryan Helmkamp)
|
29
|
+
* Switch to using Nokogiri.parse for simple XML/XHTML autodetection [#66]
|
30
|
+
* Removed Webrat.root method, which seemed to be unused
|
31
|
+
* Added Webrat.configure method for global Webrat configuration [#33]
|
32
|
+
(Mike Gaffney)
|
33
|
+
* Added automatic starting and stopping of the Selenium server and a Mongrel Rails
|
34
|
+
app server when using webrat/selenium
|
35
|
+
* Switch to using selenium-client gem and vendor selenium-server.jar (Luke Melia)
|
36
|
+
* Added gemspec so the gem builds on GitHub now
|
37
|
+
* Deprecate old style methods (fills_in is deprecated in favor of fill_in, etc.)
|
38
|
+
* Improcements to the README and RDoc (Bryan Helmkamp, Mike Gaffney)
|
39
|
+
* Allow clicking links by id and id regexp (Mike Gaffney)
|
40
|
+
* Raise Webrat::DisabledFieldError when attempting to manipulate a disabled field
|
41
|
+
* Raise Webrat::NotFoundErrors when an element is not found
|
42
|
+
* Raise Webrat::PageLoadError when a failure occurs so that application exceptions
|
43
|
+
can be more accurately tested (Ryan Briones)
|
44
|
+
* Helpful error message for missing option in select box. [#40] (Ben Mabey)
|
45
|
+
|
46
|
+
* Bug fixes
|
47
|
+
|
48
|
+
* Match against link _text_ which decodes character references.
|
49
|
+
Useful for multibyte languages like Japanese (moronatural@gmail.com)
|
50
|
+
* Fix params hash generation for Mechanize when Merb is not defined [#62]
|
51
|
+
* Expose some Webrat methods that were missing from the Webrat::Methods module
|
52
|
+
(Low Chin Chau)
|
53
|
+
* Allow mechanize session to pass through basic auth (Ryan Briones)
|
54
|
+
* Improvements to the Mechanize support (Jeremy Burks)
|
55
|
+
* Fix following fully qualified local links (Lawrence Pit)
|
56
|
+
* Fixed bug where Webrat would lose complex parameters (like foo[bar[baz]][])
|
57
|
+
in Merb due to not correctly merging Mashes. (Drew Colthorp)
|
58
|
+
* Extend Rails' ActionController::IntegrationTest instead of
|
59
|
+
ActionController::Integration::Session (Fixes using Webrat's #select method and
|
60
|
+
avoids usage of method_missing)
|
61
|
+
|
62
|
+
== 0.3.2 / 2008-11-08
|
63
|
+
|
64
|
+
* 1 Minor enhancement
|
65
|
+
|
66
|
+
* Fixes behavior or have_tag when a block is passed. It passes the matched node(s)
|
67
|
+
to the block for further specs again. (Carl Lerche)
|
68
|
+
|
69
|
+
== 0.3.1 / 2008-11-07
|
70
|
+
|
71
|
+
* 1 Minor enhancement
|
72
|
+
|
73
|
+
* Use @_webrat_session instance variable instead of @session for Merb integration
|
74
|
+
to avoid collisions
|
75
|
+
|
76
|
+
== 0.3.0 / 2008-11-07
|
77
|
+
|
78
|
+
* 4 Major enhancements
|
79
|
+
|
80
|
+
* Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman, Yehuda Katz)
|
81
|
+
* Added experimental Selenium support (Luke Melia)
|
82
|
+
* Add have_selector, have_xpath, have_tag and contain matchers from Merb
|
83
|
+
* Switch from Hpricot to Nokogiri for XML parsing (thanks, Aaron Patterson)
|
84
|
+
|
85
|
+
* 37 Minor enhancements
|
86
|
+
|
87
|
+
* Added #within for manipulating the current page within a selector scope
|
88
|
+
* Add support for file fields via #attaches_file method (Rails only at the moment)
|
89
|
+
(Kyle Hargraves)
|
90
|
+
* Add support for simulating SSL requests (Luke Melia)
|
91
|
+
* Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
|
92
|
+
* Added support for Sinatra and Rack (Aslak Hellesøy)
|
93
|
+
* Rename visits to visit, fills_in to fill_in, etc.
|
94
|
+
* Add #field_labeled for looking up form fields by label (David Chelimsky)
|
95
|
+
* Add #field_named and #field_with_id locators
|
96
|
+
* Don't depend on hoe anymore
|
97
|
+
* Return responses after sending requests
|
98
|
+
* Allow clicking links and buttons by a regular expression in Selenium (Luke Melia)
|
99
|
+
* Allow clicking links by a regular expression
|
100
|
+
* Add #http_accept for including MIME type HTTP "Accept" headers (Ryan Briones)
|
101
|
+
* Add #header to support inclusion of custom HTTP headers (Ryan Briones)
|
102
|
+
* Consider response codes 200-499 as successful enough to not raise a Webrat error
|
103
|
+
(David Leal)
|
104
|
+
* Add support for clicking areas of an image map (Alex Lang)
|
105
|
+
* Support relative links, including href="?foo=bar" (Kyle Hargraves)
|
106
|
+
* Separated Rails-specific code from the Webrat core to make it easier to use
|
107
|
+
Webrat with other environments
|
108
|
+
* Alias visits as visit, clicks_link as click_link, etc. for better readability
|
109
|
+
* Raise error when trying to interact with a disabled form element (Luke Melia)
|
110
|
+
* Don't send disabled form elements to the server (Nicholas A. Evans)
|
111
|
+
* Display response body when the page load is not successful (David Leal)
|
112
|
+
* CGI escape form field values (Miha Filej)
|
113
|
+
* Add support for redirect_to :back by sending HTTP_REFERER headers
|
114
|
+
(Hendrik Volkmer)
|
115
|
+
* Expose current DOM (as an Hpricot object) as #current_dom
|
116
|
+
* Add support for disabling JavaScript when clicking a link to enable testing of
|
117
|
+
both JS and non-JS implementations (Luke Melia and Bryan Helmkamp)
|
118
|
+
* Support  's as spaces in matching link text (Luke Melia)
|
119
|
+
* Support button elements (Nick Sieger)
|
120
|
+
* Support matching select options by regexp (Kyle Hargraves)
|
121
|
+
* save_and_open_page rewrites css and image references to provide a friendlier
|
122
|
+
debugging experience (Luke Melia)
|
123
|
+
* Added support for matching alt attributes in fields (primarly for clicks_button)
|
124
|
+
(Aaron Quint)
|
125
|
+
* Support '&' in submitted values (Kyle Hargraves)
|
126
|
+
* Support clicking links by title (Dan Barry)
|
127
|
+
* Added missing spec for clicking image buttons (Tim Harper)
|
128
|
+
* Switched tests to specs, and from Mocha to RSpec's mocking library
|
129
|
+
* Add support to click_button for IDs (Gwyn Morfey)
|
130
|
+
* Miscellaneous core refactorings (Jan Suchal)
|
131
|
+
|
132
|
+
* 8 Bug fixes
|
133
|
+
|
134
|
+
* Fix initialization of WWW::Mechanize (Derek Kastner)
|
135
|
+
* Don't open blank pages in the browser (Kyle Hargraves)
|
136
|
+
* Support radio buttons with multiple labels (Dan Barry)
|
137
|
+
* Fix load order bug on some platforms (Ismael Celis)
|
138
|
+
* Fix bug with empty select list option (Kyle Hargraves)
|
139
|
+
* Fix regression of not sending default values in password fields
|
140
|
+
* Don't explode if encountering inputs with no type attribute (assume text)
|
141
|
+
* Fix bug where choosing a radio button in a series with a default submitted the
|
142
|
+
incorrect field value (Luke Melia)
|
143
|
+
|
144
|
+
== 0.2.0 / 2008-04-04
|
145
|
+
|
146
|
+
* 4 Major enhancements
|
147
|
+
|
148
|
+
* Add save_and_open_page to aid in debugging
|
149
|
+
* Add radio button support via #chooses method
|
150
|
+
* Add basic support for Rails-generated JavaScript link tags
|
151
|
+
* Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
|
152
|
+
* Add support for textarea fields (Sacha Schlegel)
|
153
|
+
|
154
|
+
* 8 Minor enhancements
|
155
|
+
|
156
|
+
* Added reloads method to reload the page (Kamal Fariz Mahyuddi)
|
157
|
+
* Prevent making a request if clicking on local anchor link (Kamal Fariz Mahyuddi)
|
158
|
+
* Added clicks_link_within(selector, link_text), allowing restricting link search
|
159
|
+
to within a given css selector (Luke Melia)
|
160
|
+
* Allow specifying the input name/label when doing a select (David Chelimsky)
|
161
|
+
* Raise a specific exception if the developer tries to manipulate form elements
|
162
|
+
before loading a page (James Deville)
|
163
|
+
* Add support for alternate POST, PUT and DELETE link clicking (Kyle Hargraves)
|
164
|
+
* Change clicks_link to find the shortest matching link (Luke Melia)
|
165
|
+
* Improve matching for labels in potentially ambiguous cases
|
166
|
+
|
167
|
+
* 7 Bug fixes
|
168
|
+
|
169
|
+
* Fix incorrect serializing of collection inputs, i.e. name contains []
|
170
|
+
(Kamal Fariz Mahyuddi)
|
171
|
+
* Serialize empty text field values just like browsers (Kamal Fariz Mahyuddi)
|
172
|
+
* Quick fix to avoid @dom not initialized warnings (Kamal Fariz Mahyuddi)
|
173
|
+
* Docfix: bad reference to #select method in README (Luke Melia)
|
174
|
+
* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden
|
175
|
+
input with the same name)
|
176
|
+
* Fix Edge Rails (a.k.a. 2.0 RC) compatibility (David Chelimsky)
|
177
|
+
* Support param hashes nested more than one level (David Chelimsky)
|
178
|
+
|
179
|
+
== 0.1.0 / 2007-11-28
|
180
|
+
|
181
|
+
* 1 major enhancement
|
182
|
+
|
183
|
+
* Birthday!
|
184
|
+
|
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,81 @@
|
|
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::SeleniumSession 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, spec_helper.rb, or env.rb (for Cucumber) add:
|
63
|
+
|
64
|
+
require "webrat/rails"
|
65
|
+
|
66
|
+
== Install with Merb
|
67
|
+
|
68
|
+
Merb 1.0 has built-in, seamless Webrat support. Just start using
|
69
|
+
methods from Webrat::Session in your specs.
|
70
|
+
|
71
|
+
== Authors
|
72
|
+
|
73
|
+
- Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
|
74
|
+
- Original code written by {Seth Fitzsimmons}[mailto:seth@mojodna.net]
|
75
|
+
- Initial development was sponsored by EastMedia[http://www.eastmedia.com]
|
76
|
+
- Many other contributors. See attributions in History.txt
|
77
|
+
|
78
|
+
== License
|
79
|
+
|
80
|
+
Copyright (c) 2007-2008 Bryan Helmkamp, Seth Fitzsimmons.
|
81
|
+
See MIT-LICENSE.txt in this directory.
|
data/Rakefile
ADDED
@@ -0,0 +1,104 @@
|
|
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.0.6"
|
32
|
+
|
33
|
+
s.rubyforge_project = "webrat"
|
34
|
+
end
|
35
|
+
|
36
|
+
Rake::GemPackageTask.new(spec) do |package|
|
37
|
+
package.gem_spec = spec
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'Show information about the gem.'
|
41
|
+
task :debug_gem do
|
42
|
+
puts spec.to_ruby
|
43
|
+
end
|
44
|
+
|
45
|
+
CLEAN.include ["pkg", "*.gem", "doc", "ri", "coverage"]
|
46
|
+
|
47
|
+
desc "Upload rdoc to brynary.com"
|
48
|
+
task :publish_rdoc => :docs do
|
49
|
+
sh "scp -r doc/ brynary.com:/apps/uploads/webrat"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Run API and Core specs"
|
53
|
+
Spec::Rake::SpecTask.new do |t|
|
54
|
+
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
55
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "Run all specs in spec directory with RCov"
|
59
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
60
|
+
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
61
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
62
|
+
t.rcov = true
|
63
|
+
t.rcov_opts = lambda do
|
64
|
+
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
69
|
+
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'Install the package as a gem.'
|
73
|
+
task :install_gem => [:clean, :package] do
|
74
|
+
gem = Dir['pkg/*.gem'].first
|
75
|
+
sh "sudo gem install --local #{gem}"
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Delete generated RDoc"
|
79
|
+
task :clobber_docs do
|
80
|
+
FileUtils.rm_rf("doc")
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Generate RDoc"
|
84
|
+
task :docs => :clobber_docs do
|
85
|
+
system "hanna --title 'Webrat #{Webrat::VERSION} API Documentation'"
|
86
|
+
end
|
87
|
+
|
88
|
+
desc "Run specs using jruby"
|
89
|
+
task "spec:jruby" do
|
90
|
+
system "jruby -S rake spec"
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Run each spec in isolation to test for dependency issues"
|
94
|
+
task :spec_deps do
|
95
|
+
Dir["spec/**/*_spec.rb"].each do |test|
|
96
|
+
if !system("spec #{test} &> /dev/null")
|
97
|
+
puts "Dependency Issues: #{test}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
task :default => :spec
|
103
|
+
|
104
|
+
task :precommit => ["spec", "spec:jruby"]
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
|
data/lib/webrat.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
4
|
+
|
5
|
+
module Webrat
|
6
|
+
# The common base class for all exceptions raised by Webrat.
|
7
|
+
class WebratError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
VERSION = '0.3.2.1'
|
11
|
+
|
12
|
+
def self.require_xml
|
13
|
+
gem "nokogiri", ">= 1.0.6"
|
14
|
+
|
15
|
+
if on_java?
|
16
|
+
# We need Nokogiri's CSS to XPath support, even if using REXML and Hpricot for parsing and searching
|
17
|
+
require "nokogiri/css"
|
18
|
+
require "hpricot"
|
19
|
+
require "rexml/document"
|
20
|
+
else
|
21
|
+
require "nokogiri"
|
22
|
+
require "webrat/core/xml/nokogiri"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.on_java?
|
27
|
+
RUBY_PLATFORM =~ /java/
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
Webrat.require_xml
|
33
|
+
|
34
|
+
require "webrat/core"
|
data/lib/webrat/core.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "webrat/core/configuration"
|
2
|
+
require "webrat/core/xml"
|
3
|
+
require "webrat/core/xml/nokogiri"
|
4
|
+
require "webrat/core/logging"
|
5
|
+
require "webrat/core/elements/form"
|
6
|
+
require "webrat/core/scope"
|
7
|
+
require "webrat/core/elements/link"
|
8
|
+
require "webrat/core/elements/area"
|
9
|
+
require "webrat/core/elements/label"
|
10
|
+
require "webrat/core/elements/select_option"
|
11
|
+
require "webrat/core/session"
|
12
|
+
require "webrat/core/methods"
|
13
|
+
require "webrat/core/matchers"
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Webrat
|
2
|
+
|
3
|
+
# Configures Webrat. If this is not done, Webrat will be created
|
4
|
+
# with all of the default settings.
|
5
|
+
def self.configure(configuration = Webrat::Configuration.new)
|
6
|
+
yield configuration if block_given?
|
7
|
+
@@configuration = configuration
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.configuration # :nodoc:
|
11
|
+
@@configuration ||= Webrat::Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
# Webrat can be configured using the Webrat.configure method. For example:
|
15
|
+
#
|
16
|
+
# Webrat.configure do |config|
|
17
|
+
# config.parse_with_nokogiri = false
|
18
|
+
# end
|
19
|
+
class Configuration
|
20
|
+
# Should XHTML be parsed with Nokogiri? Defaults to true, except on JRuby. When false, Hpricot and REXML are used
|
21
|
+
attr_writer :parse_with_nokogiri
|
22
|
+
|
23
|
+
# Webrat's mode, set automatically when requiring webrat/rails, webrat/merb, etc.
|
24
|
+
attr_accessor :mode # :nodoc:
|
25
|
+
|
26
|
+
# Save and open pages with error status codes (500-599) in a browser? Defualts to true.
|
27
|
+
attr_writer :open_error_files
|
28
|
+
|
29
|
+
def initialize # :nodoc:
|
30
|
+
self.open_error_files = true
|
31
|
+
self.parse_with_nokogiri = !Webrat.on_java?
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse_with_nokogiri? #:nodoc:
|
35
|
+
@parse_with_nokogiri ? true : false
|
36
|
+
end
|
37
|
+
|
38
|
+
def open_error_files? #:nodoc:
|
39
|
+
@open_error_files ? true : false
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|