webrat 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +140 -30
- data/README.rdoc +85 -0
- data/Rakefile +72 -22
- data/install.rb +1 -1
- data/lib/webrat.rb +12 -17
- data/lib/webrat/core.rb +9 -7
- data/lib/webrat/core/configuration.rb +87 -0
- data/lib/webrat/core/{area.rb → elements/area.rb} +7 -20
- data/lib/webrat/core/elements/element.rb +33 -0
- data/lib/webrat/core/elements/field.rb +394 -0
- data/lib/webrat/core/elements/form.rb +103 -0
- data/lib/webrat/core/elements/label.rb +31 -0
- data/lib/webrat/core/{link.rb → elements/link.rb} +15 -26
- data/lib/webrat/core/elements/select_option.rb +35 -0
- data/lib/webrat/core/locators.rb +13 -85
- 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 +56 -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 +5 -9
- data/lib/webrat/core/matchers/have_content.rb +19 -44
- data/lib/webrat/core/matchers/have_selector.rb +15 -2
- data/lib/webrat/core/matchers/have_tag.rb +15 -2
- data/lib/webrat/core/matchers/have_xpath.rb +21 -28
- data/lib/webrat/core/methods.rb +32 -15
- data/lib/webrat/core/mime.rb +3 -3
- data/lib/webrat/core/save_and_open_page.rb +50 -0
- data/lib/webrat/core/scope.rb +183 -41
- data/lib/webrat/core/session.rb +125 -63
- data/lib/webrat/core/xml.rb +115 -0
- data/lib/webrat/core/xml/hpricot.rb +19 -0
- data/lib/webrat/core/xml/nokogiri.rb +76 -0
- data/lib/webrat/core/xml/rexml.rb +24 -0
- data/lib/webrat/core_extensions/deprecate.rb +1 -1
- data/lib/webrat/mechanize.rb +58 -12
- data/lib/webrat/merb.rb +7 -73
- data/lib/webrat/merb_session.rb +65 -0
- data/lib/webrat/rack.rb +1 -1
- data/lib/webrat/rails.rb +56 -55
- data/lib/webrat/rspec-rails.rb +13 -0
- data/lib/webrat/selenium.rb +92 -1
- data/lib/webrat/selenium/matchers.rb +146 -0
- data/lib/webrat/selenium/selenium_session.rb +179 -80
- data/lib/webrat/sinatra.rb +14 -4
- data/vendor/selenium-server.jar +0 -0
- metadata +36 -17
- data/README.txt +0 -90
- data/TODO.txt +0 -10
- data/init.rb +0 -3
- data/lib/webrat/core/field.rb +0 -332
- data/lib/webrat/core/flunk.rb +0 -7
- data/lib/webrat/core/form.rb +0 -130
- data/lib/webrat/core/label.rb +0 -18
- data/lib/webrat/core/nokogiri.rb +0 -44
- data/lib/webrat/core/select_option.rb +0 -29
- data/lib/webrat/rails/redirect_actions.rb +0 -18
data/History.txt
CHANGED
@@ -1,44 +1,145 @@
|
|
1
|
+
== 0.4.0 / 2009-01-18
|
2
|
+
|
3
|
+
* _IMPORTANT_ Breaking change:
|
4
|
+
|
5
|
+
* Removed init.rb auto-require of webrat/rails
|
6
|
+
* Removed auto-require of webrat/rails when requiring webrat when RAILS_ENV is
|
7
|
+
defined
|
8
|
+
|
9
|
+
In your env.rb or test_helper.rb file, ensure you have something like:
|
10
|
+
|
11
|
+
require "webrat"
|
12
|
+
|
13
|
+
Webrat.configure do |config|
|
14
|
+
config.mode = :rails
|
15
|
+
end
|
16
|
+
|
17
|
+
* Major enhancements
|
18
|
+
|
19
|
+
* Major improvements to Webrat::Selenium (Many contributors listed here)
|
20
|
+
* Add assert_* methods for using Webrat's matchers w/o RSpec (Mike Gaffney, Amos King)
|
21
|
+
* Added Webrat.configure method for Webrat configuration [#33] (Mike Gaffney)
|
22
|
+
* Added select_time, select_date, and select_datetime to API. [#36] (Ben Mabey)
|
23
|
+
* Use Hpricot and REXML when not parsing with Nokogiri (on JRuby, for example)
|
24
|
+
|
25
|
+
* Minor enhancements
|
26
|
+
|
27
|
+
* Added Selenium grid configuration and support. (Amos King && Cornel Borcean)
|
28
|
+
* Support passing an ActiveRecord model to #within when in Rails mode [#68] (Luke Melia)
|
29
|
+
* Make assert_* matchers in rails mode increment the assertions count [#123] (Amos King)
|
30
|
+
* Added assert_* matchers to selenium matchers [#110] (Amos King)
|
31
|
+
* Added assert_contain, assert_not_contain [#86] (Mike Gaffney, Amos King)
|
32
|
+
* Add configuration options for the Selenium environment and port (Kieran Pilkington)
|
33
|
+
* Maximize the browser window after initializing Selenium (Luke Melia)
|
34
|
+
* Better inspect output for Webrat elements
|
35
|
+
* Sets the Webrat mode with Configuration#mode= in the config block [#85] (Mike Gaffney)
|
36
|
+
* Detect if the document is XML or HTML using the Content-Type when in Rails mode
|
37
|
+
* Expose #selenium method for direct access to Selenium client
|
38
|
+
* Check nokogiri gem version before requiring nokogiri
|
39
|
+
* Include the Selenium server jar file in the gem (Bryan Helmkamp, Ben Schwarz)
|
40
|
+
* Added key_down, key_up and fire_event to Selenium session (Fernando Garcia)
|
41
|
+
* Fix outputing README during Rails plugin install (Fernando Garcia)
|
42
|
+
* Strip newlines when matching label text (Miha Filej)
|
43
|
+
* Add simple support for accessing Webrat's matchers from RSpec by requiring
|
44
|
+
"webrat/rspec-rails" (David Chelimsky)
|
45
|
+
* Support save_and_open_page in Windows and Cygwin (Mike Gaffney)
|
46
|
+
* Added RadioField#checked? to indicated whether or not a radio button is checked
|
47
|
+
(Luke Melia)
|
48
|
+
* Add spec:jruby rake task for running Webrat's spec suite with JRuby
|
49
|
+
* Added field_by_xpath to locate a Webrat::Field using arbitrary XPath expressions
|
50
|
+
* Helpful error message for missing option values [#40] (Ben Mabey)
|
51
|
+
* Add set_hidden_field method (Noah Davis, Bryan Helmkamp)
|
52
|
+
* Add submit_form method for submitting a form by ID (Noah Davis, Bryan Helmkamp)
|
53
|
+
* Switch to using Nokogiri.parse for simple XML/XHTML autodetection [#66]
|
54
|
+
* Removed Webrat.root method, which seemed to be unused
|
55
|
+
* Added automatic starting and stopping of the Selenium server and a Mongrel Rails
|
56
|
+
app server when using webrat/selenium
|
57
|
+
* Switch to using selenium-client gem and vendor selenium-server.jar (Luke Melia)
|
58
|
+
* Added gemspec so the gem builds on GitHub now
|
59
|
+
* Deprecate old style methods (fills_in is deprecated in favor of fill_in, etc.)
|
60
|
+
* Improvements to the README and RDoc (Bryan Helmkamp, Mike Gaffney)
|
61
|
+
* Allow clicking links by id and id regexp (Mike Gaffney)
|
62
|
+
* Raise Webrat::DisabledFieldError when attempting to manipulate a disabled field
|
63
|
+
* Raise Webrat::NotFoundErrors when an element is not found
|
64
|
+
* Raise Webrat::PageLoadError when a failure occurs so that application exceptions
|
65
|
+
can be more accurately tested (Ryan Briones)
|
66
|
+
* Helpful error message for missing option in select box. [#40] (Ben Mabey)
|
67
|
+
* Extracted save_and_open page to make it usable in Selenium mode (Luke Melia)
|
68
|
+
* Added save_and_open_screengrab for Selenium mode (Luke Melia)
|
69
|
+
|
70
|
+
* Bug fixes
|
71
|
+
|
72
|
+
* field_labeled should disregard labels without matching fields (Kyle Hargraves)
|
73
|
+
* Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
|
74
|
+
[#105] (Zach Dennis)
|
75
|
+
* Support Rails > v2.2 by using ActionController::RequestParser for param parsing [#107]
|
76
|
+
(Marcello Nuccio)
|
77
|
+
* Raise a Webrat::NotFoundError if the scope passed to #within doesn't exist [#90]
|
78
|
+
* Match against link _text_ which decodes character references.
|
79
|
+
Useful for multibyte languages like Japanese (moronatural@gmail.com)
|
80
|
+
* Fix params hash generation for Mechanize when Merb is not defined [#62]
|
81
|
+
* Expose some Webrat methods that were missing from the Webrat::Methods module
|
82
|
+
(Low Chin Chau)
|
83
|
+
* Allow mechanize session to pass through basic auth (Ryan Briones)
|
84
|
+
* Improvements to the Mechanize support (Jeremy Burks)
|
85
|
+
* Fix following fully qualified local links (Lawrence Pit)
|
86
|
+
* Fixed bug where Webrat would lose complex parameters (like foo[bar[baz]][])
|
87
|
+
in Merb due to not correctly merging Mashes. (Drew Colthorp)
|
88
|
+
* Extend Rails' ActionController::IntegrationTest instead of
|
89
|
+
ActionController::Integration::Session (Fixes using Webrat's #select method and
|
90
|
+
avoids usage of method_missing)
|
91
|
+
* Ensure that Webrat::MechanizeSession.request_page always uses an absolute
|
92
|
+
URL. (Graham Ashton)
|
93
|
+
* Strip anchor tags from URIs before passing to Rails integration session
|
94
|
+
(Noah Davis)
|
95
|
+
* Treat text and regexp when matching Selenium buttons (Ross Kaffenberger)
|
96
|
+
* Allow SeleniumSession's click_button to be called without an argument without
|
97
|
+
blowing up (Luke Melia)
|
98
|
+
|
1
99
|
== 0.3.4 / 2008-12-29
|
2
100
|
|
3
101
|
* 1 Minor enhancement
|
4
102
|
|
5
103
|
* Fix compatibility with Nokogiri 1.1.0 on JRuby
|
6
|
-
|
104
|
+
|
7
105
|
* 1 Bug fix
|
8
106
|
|
9
107
|
* Correct version for Nokogiri dependency in gem
|
10
|
-
|
108
|
+
|
11
109
|
== 0.3.3 / 2008-12-28
|
12
110
|
|
13
111
|
* 1 Minor enhancement
|
14
112
|
|
15
113
|
* Fix compatibility with Nokogiri 1.1.0 on MRI
|
16
|
-
|
114
|
+
|
17
115
|
== 0.3.2 / 2008-11-08
|
18
116
|
|
19
117
|
* 1 Minor enhancement
|
20
118
|
|
21
|
-
* Fixes behavior or have_tag when a block is passed. It passes the matched node(s)
|
22
|
-
|
119
|
+
* Fixes behavior or have_tag when a block is passed. It passes the matched node(s)
|
120
|
+
to the block for further specs again. (Carl Lerche)
|
121
|
+
|
23
122
|
== 0.3.1 / 2008-11-07
|
24
123
|
|
25
124
|
* 1 Minor enhancement
|
26
125
|
|
27
|
-
* Use @_webrat_session instance variable instead of @session for Merb integration
|
126
|
+
* Use @_webrat_session instance variable instead of @session for Merb integration
|
127
|
+
to avoid collisions
|
28
128
|
|
29
129
|
== 0.3.0 / 2008-11-07
|
30
130
|
|
31
|
-
* Major enhancements
|
131
|
+
* 4 Major enhancements
|
32
132
|
|
33
133
|
* Added Merb support (Gwyn Morfey, Jeremy Burks, Rob Kaufman, Yehuda Katz)
|
34
134
|
* Added experimental Selenium support (Luke Melia)
|
35
135
|
* Add have_selector, have_xpath, have_tag and contain matchers from Merb
|
36
136
|
* Switch from Hpricot to Nokogiri for XML parsing (thanks, Aaron Patterson)
|
37
|
-
|
38
|
-
* Minor enhancements
|
137
|
+
|
138
|
+
* 37 Minor enhancements
|
39
139
|
|
40
140
|
* Added #within for manipulating the current page within a selector scope
|
41
|
-
* Add support for file fields via #attaches_file method (Rails only at the moment)
|
141
|
+
* Add support for file fields via #attaches_file method (Rails only at the moment)
|
142
|
+
(Kyle Hargraves)
|
42
143
|
* Add support for simulating SSL requests (Luke Melia)
|
43
144
|
* Added #basic_auth(user, pass) to support HTTP Basic Auth (Aslak Hellesøy)
|
44
145
|
* Added support for Sinatra and Rack (Aslak Hellesøy)
|
@@ -51,33 +152,37 @@
|
|
51
152
|
* Allow clicking links by a regular expression
|
52
153
|
* Add #http_accept for including MIME type HTTP "Accept" headers (Ryan Briones)
|
53
154
|
* Add #header to support inclusion of custom HTTP headers (Ryan Briones)
|
54
|
-
* Consider response codes 200-499 as successful enough to not raise a Webrat error
|
55
|
-
|
155
|
+
* Consider response codes 200-499 as successful enough to not raise a Webrat error
|
156
|
+
(David Leal)
|
56
157
|
* Add support for clicking areas of an image map (Alex Lang)
|
57
158
|
* Support relative links, including href="?foo=bar" (Kyle Hargraves)
|
58
|
-
* Separated Rails-specific code from the Webrat core to make it easier to use
|
159
|
+
* Separated Rails-specific code from the Webrat core to make it easier to use
|
160
|
+
Webrat with other environments
|
59
161
|
* Alias visits as visit, clicks_link as click_link, etc. for better readability
|
60
162
|
* Raise error when trying to interact with a disabled form element (Luke Melia)
|
61
163
|
* Don't send disabled form elements to the server (Nicholas A. Evans)
|
62
164
|
* Display response body when the page load is not successful (David Leal)
|
63
165
|
* CGI escape form field values (Miha Filej)
|
64
|
-
* Add support for redirect_to :back by sending HTTP_REFERER headers
|
166
|
+
* Add support for redirect_to :back by sending HTTP_REFERER headers
|
167
|
+
(Hendrik Volkmer)
|
65
168
|
* Expose current DOM (as an Hpricot object) as #current_dom
|
66
|
-
* Add support for disabling JavaScript when clicking a link to enable testing of
|
67
|
-
and non-JS implementations (Luke Melia and Bryan Helmkamp)
|
169
|
+
* Add support for disabling JavaScript when clicking a link to enable testing of
|
170
|
+
both JS and non-JS implementations (Luke Melia and Bryan Helmkamp)
|
68
171
|
* Support  's as spaces in matching link text (Luke Melia)
|
69
172
|
* Support button elements (Nick Sieger)
|
70
173
|
* Support matching select options by regexp (Kyle Hargraves)
|
71
|
-
* save_and_open_page rewrites css and image references to provide a friendlier
|
72
|
-
|
174
|
+
* save_and_open_page rewrites css and image references to provide a friendlier
|
175
|
+
debugging experience (Luke Melia)
|
176
|
+
* Added support for matching alt attributes in fields (primarly for clicks_button)
|
177
|
+
(Aaron Quint)
|
73
178
|
* Support '&' in submitted values (Kyle Hargraves)
|
74
179
|
* Support clicking links by title (Dan Barry)
|
75
180
|
* Added missing spec for clicking image buttons (Tim Harper)
|
76
181
|
* Switched tests to specs, and from Mocha to RSpec's mocking library
|
77
182
|
* Add support to click_button for IDs (Gwyn Morfey)
|
78
183
|
* Miscellaneous core refactorings (Jan Suchal)
|
79
|
-
|
80
|
-
* Bug fixes
|
184
|
+
|
185
|
+
* 8 Bug fixes
|
81
186
|
|
82
187
|
* Fix initialization of WWW::Mechanize (Derek Kastner)
|
83
188
|
* Don't open blank pages in the browser (Kyle Hargraves)
|
@@ -86,8 +191,9 @@
|
|
86
191
|
* Fix bug with empty select list option (Kyle Hargraves)
|
87
192
|
* Fix regression of not sending default values in password fields
|
88
193
|
* Don't explode if encountering inputs with no type attribute (assume text)
|
89
|
-
* Fix bug where choosing a radio button in a series with a default submitted the
|
90
|
-
|
194
|
+
* Fix bug where choosing a radio button in a series with a default submitted the
|
195
|
+
incorrect field value (Luke Melia)
|
196
|
+
|
91
197
|
== 0.2.0 / 2008-04-04
|
92
198
|
|
93
199
|
* 4 Major enhancements
|
@@ -97,31 +203,35 @@
|
|
97
203
|
* Add basic support for Rails-generated JavaScript link tags
|
98
204
|
* Add support for checkboxes (Patches from Kyle Hargraves and Jarkko Laine)
|
99
205
|
* Add support for textarea fields (Sacha Schlegel)
|
100
|
-
|
206
|
+
|
101
207
|
* 8 Minor enhancements
|
102
|
-
|
208
|
+
|
103
209
|
* Added reloads method to reload the page (Kamal Fariz Mahyuddi)
|
104
210
|
* Prevent making a request if clicking on local anchor link (Kamal Fariz Mahyuddi)
|
105
|
-
* Added clicks_link_within(selector, link_text), allowing restricting link search
|
106
|
-
|
211
|
+
* Added clicks_link_within(selector, link_text), allowing restricting link search
|
212
|
+
to within a given css selector (Luke Melia)
|
107
213
|
* Allow specifying the input name/label when doing a select (David Chelimsky)
|
108
|
-
* Raise a specific exception if the developer tries to manipulate form elements
|
214
|
+
* Raise a specific exception if the developer tries to manipulate form elements
|
215
|
+
before loading a page (James Deville)
|
109
216
|
* Add support for alternate POST, PUT and DELETE link clicking (Kyle Hargraves)
|
110
217
|
* Change clicks_link to find the shortest matching link (Luke Melia)
|
111
218
|
* Improve matching for labels in potentially ambiguous cases
|
112
|
-
|
219
|
+
|
113
220
|
* 7 Bug fixes
|
114
221
|
|
115
|
-
* Fix incorrect serializing of collection inputs, i.e. name contains []
|
222
|
+
* Fix incorrect serializing of collection inputs, i.e. name contains []
|
223
|
+
(Kamal Fariz Mahyuddi)
|
116
224
|
* Serialize empty text field values just like browsers (Kamal Fariz Mahyuddi)
|
117
225
|
* Quick fix to avoid @dom not initialized warnings (Kamal Fariz Mahyuddi)
|
118
226
|
* Docfix: bad reference to #select method in README (Luke Melia)
|
119
|
-
* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden
|
227
|
+
* Ensure Rails-style checkboxes work properly (checkboxes followed by a hidden
|
228
|
+
input with the same name)
|
120
229
|
* Fix Edge Rails (a.k.a. 2.0 RC) compatibility (David Chelimsky)
|
121
230
|
* Support param hashes nested more than one level (David Chelimsky)
|
122
231
|
|
123
232
|
== 0.1.0 / 2007-11-28
|
124
233
|
|
125
234
|
* 1 major enhancement
|
235
|
+
|
126
236
|
* Birthday!
|
127
237
|
|
data/README.rdoc
ADDED
@@ -0,0 +1,85 @@
|
|
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::Selenium 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 or env.rb (for Cucumber) add:
|
63
|
+
|
64
|
+
require "webrat"
|
65
|
+
|
66
|
+
Webrat.configure do |config|
|
67
|
+
config.mode = :rails
|
68
|
+
end
|
69
|
+
|
70
|
+
== Install with Merb
|
71
|
+
|
72
|
+
Merb 1.0 has built-in, seamless Webrat support. Just start using
|
73
|
+
methods from Webrat::Session in your specs.
|
74
|
+
|
75
|
+
== Authors
|
76
|
+
|
77
|
+
- Maintained by {Bryan Helmkamp}[mailto:bryan@brynary.com]
|
78
|
+
- Original code written by {Seth Fitzsimmons}[mailto:seth@mojodna.net]
|
79
|
+
- Initial development was sponsored by EastMedia[http://www.eastmedia.com]
|
80
|
+
- Many other contributors. See attributions in History.txt
|
81
|
+
|
82
|
+
== License
|
83
|
+
|
84
|
+
Copyright (c) 2007-2008 Bryan Helmkamp, Seth Fitzsimmons.
|
85
|
+
See MIT-LICENSE.txt in this directory.
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'rubygems'
|
1
|
+
# require 'rubygems'
|
2
2
|
require "rake/gempackagetask"
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require "rake/clean"
|
5
5
|
require 'spec'
|
6
6
|
require 'spec/rake/spectask'
|
7
7
|
require 'spec/rake/verify_rcov'
|
8
|
-
require './lib/webrat.rb'
|
8
|
+
require File.expand_path('./lib/webrat.rb')
|
9
9
|
|
10
10
|
##############################################################################
|
11
11
|
# Package && release
|
@@ -21,14 +21,16 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.bindir = "bin"
|
22
22
|
s.description = s.summary
|
23
23
|
s.require_path = "lib"
|
24
|
-
s.files = %w(History.txt
|
24
|
+
s.files = %w(History.txt install.rb MIT-LICENSE.txt README.rdoc Rakefile) + Dir["lib/**/*"] + Dir["vendor/**/*"]
|
25
25
|
|
26
26
|
# rdoc
|
27
27
|
s.has_rdoc = true
|
28
|
-
s.extra_rdoc_files = %w(README.
|
28
|
+
s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
|
29
29
|
|
30
30
|
# Dependencies
|
31
31
|
s.add_dependency "nokogiri", ">= 1.1.0"
|
32
|
+
|
33
|
+
s.rubyforge_project = "webrat"
|
32
34
|
end
|
33
35
|
|
34
36
|
Rake::GemPackageTask.new(spec) do |package|
|
@@ -50,13 +52,13 @@ end
|
|
50
52
|
desc "Run API and Core specs"
|
51
53
|
Spec::Rake::SpecTask.new do |t|
|
52
54
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
53
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
55
|
+
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
54
56
|
end
|
55
57
|
|
56
58
|
desc "Run all specs in spec directory with RCov"
|
57
59
|
Spec::Rake::SpecTask.new(:rcov) do |t|
|
58
60
|
t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
59
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
61
|
+
t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
|
60
62
|
t.rcov = true
|
61
63
|
t.rcov_opts = lambda do
|
62
64
|
IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
@@ -67,23 +69,71 @@ RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
|
67
69
|
t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
|
68
70
|
end
|
69
71
|
|
70
|
-
task :default do
|
71
|
-
Rake::Task["verify_rcov"].invoke
|
72
|
-
end
|
73
|
-
|
74
72
|
desc 'Install the package as a gem.'
|
75
73
|
task :install_gem => [:clean, :package] do
|
76
|
-
|
77
|
-
sh "sudo gem install --local #{
|
74
|
+
gem_filename = Dir['pkg/*.gem'].first
|
75
|
+
sh "sudo gem install --local #{gem_filename}"
|
78
76
|
end
|
79
77
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
title
|
88
|
-
|
89
|
-
|
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 :prepare do
|
103
|
+
system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat"
|
104
|
+
end
|
105
|
+
|
106
|
+
namespace :spec do
|
107
|
+
desc "Run the integration specs"
|
108
|
+
task :integration => ["integration:rails", "integration:merb", "integration:sinatra"]
|
109
|
+
|
110
|
+
namespace :integration do
|
111
|
+
desc "Run the Rails integration specs"
|
112
|
+
task :rails do
|
113
|
+
Dir.chdir "spec/integration/rails" do
|
114
|
+
result = system "rake test:integration"
|
115
|
+
raise "Rails integration tests failed" unless result
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
desc "Run the Merb integration specs"
|
120
|
+
task :merb do
|
121
|
+
Dir.chdir "spec/integration/merb" do
|
122
|
+
result = system "rake spec"
|
123
|
+
raise "Merb integration tests failed" unless result
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
desc "Run the Sinatra integration specs"
|
128
|
+
task :sinatra do
|
129
|
+
Dir.chdir "spec/integration/sinatra" do
|
130
|
+
result = system "rake test"
|
131
|
+
raise "Sinatra tntegration tests failed" unless result
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
task :default => :spec
|
138
|
+
|
139
|
+
task :precommit => ["spec", "spec:jruby", "spec:integration"]
|