capybara 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +39 -0
- data/README.rdoc +181 -57
- data/Rakefile +7 -16
- data/config.ru +6 -0
- data/lib/capybara.rb +19 -9
- data/lib/capybara/cucumber.rb +4 -0
- data/lib/capybara/driver/base.rb +25 -8
- data/lib/capybara/driver/celerity_driver.rb +108 -0
- data/lib/capybara/driver/culerity_driver.rb +1 -70
- data/lib/capybara/driver/rack_test_driver.rb +57 -25
- data/lib/capybara/driver/selenium_driver.rb +28 -10
- data/lib/capybara/dsl.rb +7 -4
- data/lib/capybara/node.rb +50 -29
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/save_and_open_page.rb +1 -1
- data/lib/capybara/searchable.rb +45 -0
- data/lib/capybara/server.rb +11 -4
- data/lib/capybara/session.rb +94 -94
- data/lib/capybara/wait_until.rb +23 -0
- data/lib/capybara/xpath.rb +55 -41
- data/spec/capybara_spec.rb +18 -0
- data/spec/driver/celerity_driver_spec.rb +17 -0
- data/spec/driver/culerity_driver_spec.rb +3 -0
- data/spec/driver/rack_test_driver_spec.rb +3 -0
- data/spec/driver/remote_culerity_driver_spec.rb +19 -0
- data/spec/driver/remote_selenium_driver_spec.rb +18 -0
- data/spec/driver/selenium_driver_spec.rb +2 -0
- data/spec/drivers_spec.rb +51 -5
- data/spec/dsl/all_spec.rb +38 -0
- data/spec/dsl/attach_file_spec.rb +66 -0
- data/spec/dsl/check_spec.rb +28 -0
- data/spec/dsl/choose_spec.rb +28 -0
- data/spec/dsl/click_button_spec.rb +183 -0
- data/spec/dsl/click_link_spec.rb +88 -0
- data/spec/dsl/click_spec.rb +26 -0
- data/spec/dsl/current_url_spec.rb +10 -0
- data/spec/dsl/fill_in_spec.rb +83 -0
- data/spec/dsl/find_button_spec.rb +18 -0
- data/spec/dsl/find_field_spec.rb +24 -0
- data/spec/dsl/find_link_spec.rb +19 -0
- data/spec/dsl/find_spec.rb +36 -0
- data/spec/dsl/has_content_spec.rb +103 -0
- data/spec/dsl/has_css_spec.rb +109 -0
- data/spec/dsl/has_xpath_spec.rb +115 -0
- data/spec/dsl/locate_spec.rb +38 -0
- data/spec/dsl/select_spec.rb +27 -0
- data/spec/dsl/uncheck_spec.rb +29 -0
- data/spec/dsl/within_spec.rb +145 -0
- data/spec/fixtures/capybara.jpg +0 -0
- data/spec/public/test.js +27 -0
- data/spec/searchable_spec.rb +61 -0
- data/spec/server_spec.rb +47 -0
- data/spec/session/celerity_session_spec.rb +27 -0
- data/spec/session/culerity_session_spec.rb +1 -0
- data/spec/session/rack_test_session_spec.rb +1 -0
- data/spec/session/selenium_session_spec.rb +1 -0
- data/spec/session_spec.rb +32 -903
- data/spec/session_with_headers_support_spec.rb +13 -0
- data/spec/session_with_javascript_support_spec.rb +165 -0
- data/spec/session_without_headers_support_spec.rb +15 -0
- data/spec/session_without_javascript_support_spec.rb +15 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/test_app.rb +9 -1
- data/spec/views/form.erb +38 -0
- data/spec/views/postback.erb +13 -0
- data/spec/views/with_html.erb +13 -0
- data/spec/views/with_js.erb +9 -24
- data/spec/views/with_simple_html.erb +1 -1
- data/spec/wait_until_spec.rb +28 -0
- data/spec/xpath_spec.rb +34 -3
- metadata +54 -5
data/Manifest.txt
CHANGED
@@ -2,9 +2,11 @@ History.txt
|
|
2
2
|
Manifest.txt
|
3
3
|
README.rdoc
|
4
4
|
Rakefile
|
5
|
+
config.ru
|
5
6
|
lib/capybara.rb
|
6
7
|
lib/capybara/cucumber.rb
|
7
8
|
lib/capybara/driver/base.rb
|
9
|
+
lib/capybara/driver/celerity_driver.rb
|
8
10
|
lib/capybara/driver/culerity_driver.rb
|
9
11
|
lib/capybara/driver/rack_test_driver.rb
|
10
12
|
lib/capybara/driver/selenium_driver.rb
|
@@ -12,33 +14,70 @@ lib/capybara/dsl.rb
|
|
12
14
|
lib/capybara/node.rb
|
13
15
|
lib/capybara/rails.rb
|
14
16
|
lib/capybara/save_and_open_page.rb
|
17
|
+
lib/capybara/searchable.rb
|
15
18
|
lib/capybara/server.rb
|
16
19
|
lib/capybara/session.rb
|
20
|
+
lib/capybara/wait_until.rb
|
17
21
|
lib/capybara/xpath.rb
|
18
22
|
script/console
|
19
23
|
script/destroy
|
20
24
|
script/generate
|
25
|
+
spec/capybara_spec.rb
|
26
|
+
spec/driver/celerity_driver_spec.rb
|
21
27
|
spec/driver/culerity_driver_spec.rb
|
22
28
|
spec/driver/rack_test_driver_spec.rb
|
29
|
+
spec/driver/remote_culerity_driver_spec.rb
|
30
|
+
spec/driver/remote_selenium_driver_spec.rb
|
23
31
|
spec/driver/selenium_driver_spec.rb
|
24
32
|
spec/drivers_spec.rb
|
33
|
+
spec/dsl/all_spec.rb
|
34
|
+
spec/dsl/attach_file_spec.rb
|
35
|
+
spec/dsl/check_spec.rb
|
36
|
+
spec/dsl/choose_spec.rb
|
37
|
+
spec/dsl/click_button_spec.rb
|
38
|
+
spec/dsl/click_link_spec.rb
|
39
|
+
spec/dsl/click_spec.rb
|
40
|
+
spec/dsl/current_url_spec.rb
|
41
|
+
spec/dsl/fill_in_spec.rb
|
42
|
+
spec/dsl/find_button_spec.rb
|
43
|
+
spec/dsl/find_field_spec.rb
|
44
|
+
spec/dsl/find_link_spec.rb
|
45
|
+
spec/dsl/find_spec.rb
|
46
|
+
spec/dsl/has_content_spec.rb
|
47
|
+
spec/dsl/has_css_spec.rb
|
48
|
+
spec/dsl/has_xpath_spec.rb
|
49
|
+
spec/dsl/locate_spec.rb
|
50
|
+
spec/dsl/select_spec.rb
|
51
|
+
spec/dsl/uncheck_spec.rb
|
52
|
+
spec/dsl/within_spec.rb
|
25
53
|
spec/dsl_spec.rb
|
54
|
+
spec/fixtures/capybara.jpg
|
26
55
|
spec/fixtures/test_file.txt
|
27
56
|
spec/public/jquery-ui.js
|
28
57
|
spec/public/jquery.js
|
58
|
+
spec/public/test.js
|
29
59
|
spec/save_and_open_page_spec.rb
|
60
|
+
spec/searchable_spec.rb
|
61
|
+
spec/server_spec.rb
|
62
|
+
spec/session/celerity_session_spec.rb
|
30
63
|
spec/session/culerity_session_spec.rb
|
31
64
|
spec/session/rack_test_session_spec.rb
|
32
65
|
spec/session/selenium_session_spec.rb
|
33
66
|
spec/session_spec.rb
|
67
|
+
spec/session_with_headers_support_spec.rb
|
68
|
+
spec/session_with_javascript_support_spec.rb
|
69
|
+
spec/session_without_headers_support_spec.rb
|
70
|
+
spec/session_without_javascript_support_spec.rb
|
34
71
|
spec/spec_helper.rb
|
35
72
|
spec/test_app.rb
|
36
73
|
spec/views/buttons.erb
|
37
74
|
spec/views/fieldsets.erb
|
38
75
|
spec/views/form.erb
|
76
|
+
spec/views/postback.erb
|
39
77
|
spec/views/tables.erb
|
40
78
|
spec/views/with_html.erb
|
41
79
|
spec/views/with_js.erb
|
42
80
|
spec/views/with_scope.erb
|
43
81
|
spec/views/with_simple_html.erb
|
82
|
+
spec/wait_until_spec.rb
|
44
83
|
spec/xpath_spec.rb
|
data/README.rdoc
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
Capybara aims to simplify the process of integration testing Rack applications,
|
8
8
|
such as Rails, Sinatra or Merb. It is inspired by and aims to replace Webrat as
|
9
9
|
a DSL for interacting with a webapplication. It is agnostic about the driver
|
10
|
-
running your tests and currently comes bundled with rack-test, Culerity
|
11
|
-
Selenium support built in.
|
10
|
+
running your tests and currently comes bundled with rack-test, Culerity,
|
11
|
+
Celerity and Selenium support built in.
|
12
12
|
|
13
13
|
== Install:
|
14
14
|
|
@@ -26,18 +26,15 @@ Capybara is hosted on Gemcutter, install it with:
|
|
26
26
|
== Using Capybara with Cucumber
|
27
27
|
|
28
28
|
Capybara is built to work nicely with Cucumber. The API is very similar to
|
29
|
-
Webrat, so if you know Webrat you should feel right at home.
|
30
|
-
|
29
|
+
Webrat, so if you know Webrat you should feel right at home. Support for
|
30
|
+
Capybara is built into cucumber-rails 0.2. In your Rails app, just run:
|
31
31
|
|
32
|
-
|
32
|
+
script/generate cucumber --capybara
|
33
33
|
|
34
|
-
|
35
|
-
env.rb. For Rails do this:
|
34
|
+
And everything should be set up and ready to go.
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
For other frameworks, you'll need to set the Rack app manually:
|
36
|
+
If you want to use Capybara with Cucumber outside Rails (for example with Merb
|
37
|
+
or Sinatra), you'll need require capybara and set the Rack app manually:
|
41
38
|
|
42
39
|
require 'capybara/cucumber'
|
43
40
|
Capybara.app = MyRackApp
|
@@ -66,11 +63,15 @@ You can change the driver temporarily:
|
|
66
63
|
Capybara.current_driver = :culerity
|
67
64
|
Capybara.use_default_driver
|
68
65
|
|
66
|
+
You can do this in Before and After blocks to temporarily switch to a different
|
67
|
+
driver. Note that switching driver creates a new session, so you may not be able
|
68
|
+
to switch in the middle of a Scenario.
|
69
|
+
|
69
70
|
== Cucumber and Tags
|
70
71
|
|
71
72
|
Capybara sets up some {tags}[http://wiki.github.com/aslakhellesoy/cucumber/tags]
|
72
|
-
for you to use in Cucumber. Often you'll want to
|
73
|
-
|
73
|
+
for you to use in Cucumber. Often you'll want to run only some scenarios with a
|
74
|
+
driver that supports JavaScript, Capybara makes this easy: simply tag the
|
74
75
|
scenario (or feature) with <tt>@javascript</tt>:
|
75
76
|
|
76
77
|
@javascript
|
@@ -82,51 +83,182 @@ You can change which driver Capybara uses for JavaScript:
|
|
82
83
|
|
83
84
|
Capybara.javascript_driver = :culerity
|
84
85
|
|
85
|
-
There are also explicit <tt>@selenium</tt>, <tt>@culerity</tt> and
|
86
|
-
for you.
|
86
|
+
There are also explicit <tt>@selenium</tt>, <tt>@culerity</tt> and
|
87
|
+
<tt>@rack_test</tt> tags set up for you.
|
88
|
+
|
89
|
+
== Selenium
|
90
|
+
|
91
|
+
At the moment, Capybara supports Webdriver, also called Selenium 2.0, *not*
|
92
|
+
Selenium RC. Provided Firefox is installed, everything is set up for you, and
|
93
|
+
you should be able to start using Selenium right away.
|
94
|
+
|
95
|
+
== Celerity
|
96
|
+
|
97
|
+
Celerity only runs on JRuby, so you'll need to install the celerity gem under
|
98
|
+
JRuby:
|
99
|
+
|
100
|
+
jruby -S gem install celerity
|
101
|
+
|
102
|
+
Note that some specs currently fail on celerity 0.7.5, due to a bug in recent
|
103
|
+
versions of HTMLUnit. It is recommended you use celerity 0.7.4 for the time
|
104
|
+
being.
|
105
|
+
|
106
|
+
== Culerity
|
107
|
+
|
108
|
+
Install celerity as noted above, make sure JRuby is in your path. Note that
|
109
|
+
Culerity doesn't seem to be working under Ruby 1.9 at the moment.
|
110
|
+
|
111
|
+
== The DSL
|
112
|
+
|
113
|
+
Capybara's DSL is inspired by Webrat. While backwards compatibility is retained
|
114
|
+
in a lot of cases, there are certain important differences.
|
115
|
+
|
116
|
+
Unlike in Webrat, all searches in Capybara are *case sensitive*. This is because
|
117
|
+
Capybara heavily uses XPath, which doesn't support case insensitivity.
|
118
|
+
|
119
|
+
=== Navigating
|
120
|
+
|
121
|
+
You can use the <tt>visit</tt> method to navigate to other pages:
|
122
|
+
|
123
|
+
visit('/projects')
|
124
|
+
visit(post_comments_path(post))
|
125
|
+
|
126
|
+
The visit method only takes a single parameter, the request method is *always*
|
127
|
+
GET.
|
128
|
+
|
129
|
+
=== Clicking links and buttons
|
130
|
+
|
131
|
+
You can interact with the webapp by following links and buttons. Capybara
|
132
|
+
automatically follows any redirects, and submits forms associated with buttons.
|
133
|
+
|
134
|
+
click_link('id-of-link')
|
135
|
+
click_link('Link Text')
|
136
|
+
click_button('Save')
|
137
|
+
click('Link Text') # Click either a link or a button
|
138
|
+
click('Button Value')
|
139
|
+
|
140
|
+
=== Interacting with forms
|
141
|
+
|
142
|
+
Forms are everywhere in webapps, there are a number of tools for interacting
|
143
|
+
with the various form elements:
|
144
|
+
|
145
|
+
fill_in('First Name', :with => 'John')
|
146
|
+
fill_in('Password', :with => 'Seekrit')
|
147
|
+
fill_in('Description', :with => 'Really Long Text…')
|
148
|
+
choose('An Option')
|
149
|
+
check('A Checkbox')
|
150
|
+
uncheck('A Checkbox')
|
151
|
+
attach_file('Image', '/path/to/image.jpg')
|
152
|
+
select('Option', :from => 'Select Box')
|
87
153
|
|
88
|
-
|
154
|
+
=== Scoping
|
89
155
|
|
90
|
-
|
156
|
+
Capybara makes it possible to restrict certain actions, such as interacting with
|
157
|
+
forms or clicking links and buttons, to within a specific area of the page. For
|
158
|
+
this purpose you can use the generic <tt>within</tt> method. Optionally you can
|
159
|
+
specify which kind of selector (CSS or XPath to use).
|
91
160
|
|
92
|
-
|
161
|
+
within("//li[@id='employee']") do
|
162
|
+
fill_in 'Name', :with => 'Jimmy'
|
163
|
+
end
|
164
|
+
|
165
|
+
within(:css, "li#employee") do
|
166
|
+
fill_in 'Name', :with => 'Jimmy'
|
167
|
+
end
|
168
|
+
|
169
|
+
You can choose which kind of selector Capybara uses by default, by setting
|
170
|
+
<tt>Capybara.default_selector</tt>.
|
93
171
|
|
94
|
-
|
172
|
+
There are special methods for restricting the scope to a specific fieldset,
|
173
|
+
identified by either an id or the text of the fieldet's legend tag, and to a
|
174
|
+
specific table, identified by either idea or text of the table's caption tag.
|
95
175
|
|
96
|
-
|
97
|
-
|
98
|
-
|
176
|
+
within_fieldset('Employee') do
|
177
|
+
fill_in 'Name', :with => 'Jimmy'
|
178
|
+
end
|
179
|
+
|
180
|
+
within_table('Employee') do
|
181
|
+
fill_in 'Name', :with => 'Jimmy'
|
182
|
+
end
|
99
183
|
|
100
|
-
|
184
|
+
=== Querying
|
101
185
|
|
102
|
-
|
103
|
-
|
104
|
-
fill_in
|
105
|
-
choose
|
106
|
-
check
|
107
|
-
uncheck
|
108
|
-
attach_file
|
109
|
-
select
|
186
|
+
Capybara has a rich set of options for querying the page for the existence of
|
187
|
+
certain elements, and working with and manipulating those elements.
|
110
188
|
|
111
|
-
|
189
|
+
page.has_xpath?('//table/tr')
|
190
|
+
page.has_css?('table tr.foo')
|
191
|
+
page.has_content?('foo')
|
192
|
+
|
193
|
+
You can use with RSpecs magic matchers:
|
112
194
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
find_field
|
118
|
-
find_link
|
119
|
-
find_button
|
120
|
-
field_labeled
|
195
|
+
page.should have_xpath('//table/tr')
|
196
|
+
page.should have_css('table tr.foo')
|
197
|
+
page.should have_content('foo')
|
198
|
+
page.should have_no_content('foo')
|
121
199
|
|
122
|
-
|
200
|
+
Note that <tt>page.should have_no_xpath</tt> is preferred over
|
201
|
+
<tt>page.should_not have_xpath</tt>. Read the section on asynchronous JavaScript
|
202
|
+
for an explanation.
|
123
203
|
|
124
|
-
|
204
|
+
You can also find specific elements, in order to manipulate them:
|
125
205
|
|
126
|
-
|
206
|
+
find_field('First Name').value
|
207
|
+
find_link('Hello').visible?
|
208
|
+
find_button('Send').click
|
209
|
+
|
210
|
+
find('//table/tr').click
|
211
|
+
wait_for("//*[@id='overlay'").find("//h1").click
|
212
|
+
all('a').each { |a| a[:href] }
|
213
|
+
|
214
|
+
=== Scripting
|
215
|
+
|
216
|
+
In drivers which support it, you can easily evaluate JavaScript:
|
217
|
+
|
218
|
+
result = page.evaluate_script('4 + 4');
|
219
|
+
|
220
|
+
=== Debugging
|
221
|
+
|
222
|
+
It can be useful to take a snapshot of the page as it currently is and take a
|
223
|
+
look at it:
|
127
224
|
|
128
225
|
save_and_open_page
|
129
226
|
|
227
|
+
== Asynchronous JavaScript (AJAX and friends)
|
228
|
+
|
229
|
+
When working with asynchronous JavaScript, you might come across situations
|
230
|
+
where you are attempting to interact with an element which is not yet present
|
231
|
+
on the page. Capybara automatically deals with this by waiting for elements
|
232
|
+
to appear on the page.
|
233
|
+
|
234
|
+
When issuing instructions to the DSL such as:
|
235
|
+
|
236
|
+
click_link('foo')
|
237
|
+
click_link('bar')
|
238
|
+
page.should have_content('baz')
|
239
|
+
|
240
|
+
If clicking on the *foo* link causes triggers an asynchronous process, such as
|
241
|
+
an AJAX request, which, when complete will add the *bar* link to the page,
|
242
|
+
clicking on the *bar* link would be expeced to fail, since that link doesn't
|
243
|
+
exist yet. However Capybara is smart enought to retry finding the link for a
|
244
|
+
brief period of time before giving up and throwing an error. The same is true of
|
245
|
+
the next line, which looks for the content *baz* on the page; it will retry
|
246
|
+
looking for that content for a brief time. You can adjust how long this period
|
247
|
+
is (the default is 2 seconds):
|
248
|
+
|
249
|
+
Capybara.default_wait_time = 5
|
250
|
+
|
251
|
+
Be aware that because of this behaviour, the following two statements are *not*
|
252
|
+
identical, and you should *always* use the latter!
|
253
|
+
|
254
|
+
page.should_not have_xpath('//a')
|
255
|
+
page.should have_no_xpath('//a')
|
256
|
+
|
257
|
+
The former would incorrectly wait for the content to appear, since the
|
258
|
+
asynchronous process has not yet removed the element from the page, it would
|
259
|
+
therefore fail, even though the code might be working correctly. The latter
|
260
|
+
correctly wait for the element to disappear from the page.
|
261
|
+
|
130
262
|
== Using the DSL outside cucumber
|
131
263
|
|
132
264
|
You can mix the DSL into any context, for example you could use it in RSpec
|
@@ -173,26 +305,12 @@ moving from Webrat and used CSS a lot, or simply generally prefer CSS:
|
|
173
305
|
|
174
306
|
== Gotchas:
|
175
307
|
|
176
|
-
* Install JRuby and the 'celerity' gem, version 0.7.4 (0.7.5 has a bug with
|
177
|
-
password fields) under JRuby for Culerity support.
|
178
|
-
|
179
|
-
* Everything is *case sensitive*. Capybara heavily relies on XPath, which
|
180
|
-
doesn't support case insensitive searches.
|
181
|
-
|
182
|
-
* The <tt>have_tag</tt> and <tt>have_text</tt> matchers in RSpec-Rails are not
|
183
|
-
supported. You should use <tt>page.should have_css('#header p')</tt>,
|
184
|
-
<tt>page.should have_xpath('//ul/li')</tt> and <tt>page.should
|
185
|
-
have_content('Monkey')</tt> instead.
|
186
|
-
|
187
308
|
* Domain names (including subdomains) don't work under rack-test. Since it's a
|
188
309
|
pain to set up subdomains for the other drivers anyway, you should consider an
|
189
310
|
alternate solution. You might use
|
190
311
|
{default_url_options}[https://gist.github.com/643a758320a2926bd2ed] in Rails
|
191
312
|
for example.
|
192
313
|
|
193
|
-
* The <tt>set_hidden_field</tt> method from Webrat is not implemented, since it doesn't
|
194
|
-
work in any of the browser based drivers (Culerity, Selenium)
|
195
|
-
|
196
314
|
* Access to session, request and response from the test is not possible. Maybe
|
197
315
|
we'll do response headers at some point in the future, but the others really
|
198
316
|
shouldn't be touched in an integration test anyway.
|
@@ -214,6 +332,12 @@ The following people have dedicated their time and effort to Capybara:
|
|
214
332
|
* Wincent Colaiuta
|
215
333
|
* Andrea Fazzi
|
216
334
|
* Aslak Hellesøy
|
335
|
+
* Andrew Brown
|
336
|
+
* Lenny Marks
|
337
|
+
* Aaron Patterson
|
338
|
+
* Dan Dofter
|
339
|
+
* Thorbjørn Hermansen
|
340
|
+
* Louis T.
|
217
341
|
|
218
342
|
== License:
|
219
343
|
|
data/Rakefile
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
|
2
3
|
gem 'hoe', '>= 2.1.0'
|
3
4
|
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/capybara'
|
6
5
|
|
7
6
|
Hoe.plugin :newgem
|
8
|
-
# Hoe.plugin :website
|
9
|
-
# Hoe.plugin :cucumberfeatures
|
10
7
|
|
11
8
|
# Generate all the Rake tasks
|
12
9
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
self.readme_file
|
17
|
-
self.extra_rdoc_files = ['
|
10
|
+
Hoe.spec 'capybara' do
|
11
|
+
developer 'Jonas Nicklas', 'jonas.nicklas@gmail.com'
|
12
|
+
|
13
|
+
self.readme_file = 'README.rdoc'
|
14
|
+
self.extra_rdoc_files = Dir['*.rdoc']
|
18
15
|
|
19
16
|
self.extra_deps = [
|
20
17
|
['nokogiri', '>= 1.3.3'],
|
18
|
+
['mime-types', '>= 1.16'],
|
21
19
|
['culerity', '>= 0.2.4'],
|
22
20
|
['selenium-webdriver', '>= 0.0.3'],
|
23
21
|
['rack', '>= 1.0.0'],
|
@@ -29,10 +27,3 @@ $hoe = Hoe.spec 'capybara' do
|
|
29
27
|
['rspec', '>= 1.2.9']
|
30
28
|
]
|
31
29
|
end
|
32
|
-
|
33
|
-
require 'newgem/tasks'
|
34
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
35
|
-
|
36
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
37
|
-
# remove_task :default
|
38
|
-
# task :default => [:spec, :features]
|
data/config.ru
ADDED
data/lib/capybara.rb
CHANGED
@@ -1,20 +1,28 @@
|
|
1
|
+
require 'timeout'
|
1
2
|
require 'nokogiri'
|
2
3
|
|
3
4
|
module Capybara
|
4
|
-
VERSION = '0.
|
5
|
+
VERSION = '0.3.0'
|
5
6
|
|
6
7
|
class CapybaraError < StandardError; end
|
7
8
|
class DriverNotFoundError < CapybaraError; end
|
8
9
|
class ElementNotFound < CapybaraError; end
|
9
10
|
class NotSupportedByDriverError < CapybaraError; end
|
10
|
-
|
11
|
+
class TimeoutError < CapybaraError; end
|
12
|
+
class InfiniteRedirectError < TimeoutError; end
|
13
|
+
|
11
14
|
class << self
|
12
|
-
attr_accessor :debug, :asset_root
|
13
|
-
attr_writer :default_selector
|
15
|
+
attr_accessor :debug, :asset_root, :app_host
|
16
|
+
attr_writer :default_selector, :default_wait_time
|
17
|
+
|
14
18
|
|
15
19
|
def default_selector
|
16
20
|
@default_selector ||= :xpath
|
17
21
|
end
|
22
|
+
|
23
|
+
def default_wait_time
|
24
|
+
@default_wait_time ||= 2
|
25
|
+
end
|
18
26
|
|
19
27
|
def log(message)
|
20
28
|
puts "[capybara] #{message}" if debug
|
@@ -22,14 +30,16 @@ module Capybara
|
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
|
-
autoload :Server,
|
26
|
-
autoload :Session,
|
27
|
-
autoload :Node,
|
28
|
-
autoload :XPath,
|
29
|
-
|
33
|
+
autoload :Server, 'capybara/server'
|
34
|
+
autoload :Session, 'capybara/session'
|
35
|
+
autoload :Node, 'capybara/node'
|
36
|
+
autoload :XPath, 'capybara/xpath'
|
37
|
+
autoload :Searchable, 'capybara/searchable'
|
38
|
+
|
30
39
|
module Driver
|
31
40
|
autoload :Base, 'capybara/driver/base'
|
32
41
|
autoload :RackTest, 'capybara/driver/rack_test_driver'
|
42
|
+
autoload :Celerity, 'capybara/driver/celerity_driver'
|
33
43
|
autoload :Culerity, 'capybara/driver/culerity_driver'
|
34
44
|
autoload :Selenium, 'capybara/driver/selenium_driver'
|
35
45
|
end
|