capybara-extensions 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/CHANGELOG.md +12 -0
- data/README.md +13 -7
- data/capybara-extensions.gemspec +2 -1
- data/lib/capybara-extensions.rb +1 -1
- data/lib/capybara-extensions/finders.rb +45 -31
- data/lib/capybara-extensions/version.rb +1 -1
- data/test/finders_test.rb +96 -8
- data/test/string.rb +23 -22
- metadata +42 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3b2150c1b62de9f239d8ab643f0695af0b4c04
|
4
|
+
data.tar.gz: 7db3b4f7ec378c493de31e38ecf4dbe25acdb240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffed4e03d7c04954d3a8c4265a232d61016cd7e0e1257c604d6c77a02657766acb5f4ab1e247805ccf7a728cbfd2b27796b360efbb1cacb70b61ad126d4459c0
|
7
|
+
data.tar.gz: 8c5562ffc7379f3e5db9a27a46ef0b356dd7bd3524508262b50118d0a3249628b73852b3d1460093d0b9b999564dbeab59343dfc227b295d158ddb7dcc72bb9e
|
data/.travis.yml
CHANGED
@@ -2,3 +2,10 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
4
|
cache: bundler
|
5
|
+
|
6
|
+
notifications:
|
7
|
+
hipchat:
|
8
|
+
rooms:
|
9
|
+
secure: Y2vwGdS1AlZXgzSlE/TaUfL/yY33JewipRE8pUbXkcizu9GFAuNpv9DDL/p+GijWKdl0U2Lo4GiXiUhqky1NHMa3hU1kairq1djYJrRWEhT9nj3qfjqGvX8sl5YmiBSWjv+4o91K6IdIxcJ9/sLMQU02Lp4ABgIQJqtSUhEciAY=
|
10
|
+
template:
|
11
|
+
- '@all %{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.4.0
|
4
|
+
* Updates the `#first_` method so that when no argument is passed the
|
5
|
+
first occurrence of the element is found.
|
6
|
+
* Updates `README.md` with information about setting up `Capybara'.
|
7
|
+
|
8
|
+
## 0.3.4
|
9
|
+
* Adds `capybara, ~> 2.2.0` as a runtime dependency.
|
10
|
+
* Fixes the calling of `CapybaraExtensions.extension_methods` when defining
|
11
|
+
`Capybara::Session` methods.
|
12
|
+
* Updates the README.
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[Capybara](https://github.com/jnicklas/capybara) has an intuitive API which mimics the language of an actual user. This library extends Capybara's finders and matchers with additional methods for interacting with tables, lists, and list items, as well as many HTML5 elements.
|
7
7
|
|
8
8
|
## Installation
|
9
|
-
Add this line to your application's Gemfile:
|
9
|
+
Add this line to your application's Gemfile to install from [RubyGems](https://rubygems.org/gems/capybara-extensions):
|
10
10
|
|
11
11
|
gem 'capybara-extensions'
|
12
12
|
|
@@ -19,7 +19,12 @@ Or install it yourself as:
|
|
19
19
|
$ gem install capybara-extensions
|
20
20
|
|
21
21
|
## Setup
|
22
|
-
|
22
|
+
Ensure that Capybara is properly setup inside of your project. You can
|
23
|
+
view the Capybara `README.md`
|
24
|
+
[here](https://github.com/jnicklas/capybara#setup).
|
25
|
+
|
26
|
+
Require `capybara-extensions` (in your test helper file if this is a
|
27
|
+
Rails project):
|
23
28
|
|
24
29
|
```ruby
|
25
30
|
require 'capybara-extensions'
|
@@ -48,11 +53,10 @@ within form('Login') do
|
|
48
53
|
end
|
49
54
|
```
|
50
55
|
|
51
|
-
Each `find` method also has a corresponding `first` method. So when you have multiple article elements on a page with the text 'Lorem ipsum,' you can call `first_article('Lorem ipsum')` without returning an ambiguous match in Capybara.
|
56
|
+
Each `find` method also has a corresponding `first` method. So when you have multiple article elements on a page with the text 'Lorem ipsum,' you can call `first_article('Lorem ipsum')` without returning an ambiguous match in Capybara. If you don't supply an argument to `#first_article`, it will return the first article regardless of the article's content.
|
52
57
|
|
53
|
-
In instances when you have lists or tables and you'd like to verify the content of a specific `li` or `tr`, `CapybaraExtensions` allows you to target the nth occurence of the element via `#list_item_number` and `#row_number`.
|
58
|
+
In instances when you have lists or tables and you'd like to verify the content of a specific `li` or `tr`, `CapybaraExtensions` allows you to target the nth occurence of the element via `#list_item_number` and `#row_number`. Counting is 1-based, rather than 0-based, so given the following HTML:
|
54
59
|
|
55
|
-
So given the following HTML:
|
56
60
|
```html
|
57
61
|
<ul>
|
58
62
|
<li>John Doe</li>
|
@@ -62,11 +66,13 @@ So given the following HTML:
|
|
62
66
|
```
|
63
67
|
|
64
68
|
You can find the second li with:
|
69
|
+
|
65
70
|
```ruby
|
66
71
|
list_item_number(2) # => 'Jane Doe'
|
67
72
|
```
|
68
73
|
|
69
|
-
|
74
|
+
You can also pass a negative number to these methods, and it will look
|
75
|
+
for the nth occurence from the **last** element (be it a `li` or `tr`). Use these methods for testing how elements are being ordered.
|
70
76
|
|
71
77
|
### Matchers
|
72
78
|
`CapybaraExtensions` extends Capybara's matchers with methods for verifying the presence of images, the value of input fields, and the presence of meta tags. All of these methods return a boolean.
|
@@ -97,7 +103,7 @@ Please see our [contribution guidelines](/CONTRIBUTING.md) on how to
|
|
97
103
|
properly submit issues and pull requests.
|
98
104
|
|
99
105
|
## Legal
|
100
|
-
[DockYard, Inc](http://dockyard.com) ©
|
106
|
+
[DockYard, Inc](http://dockyard.com) © 2014
|
101
107
|
|
102
108
|
Licensed under the [MIT
|
103
109
|
license](http://www.opensource.org/licenses/mit-license.php).
|
data/capybara-extensions.gemspec
CHANGED
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
22
|
spec.add_development_dependency 'byebug'
|
23
23
|
spec.add_development_dependency 'capybara_minitest_spec'
|
24
|
+
spec.add_development_dependency 'm', '~> 1.3.2'
|
24
25
|
spec.add_development_dependency 'minitest', '< 5.0'
|
25
26
|
spec.add_development_dependency 'minitest-reporters', '~> 0.14.21'
|
26
27
|
spec.add_development_dependency 'rake'
|
27
28
|
spec.add_development_dependency 'yard'
|
28
29
|
|
29
|
-
spec.add_runtime_dependency 'capybara', '~> 2.
|
30
|
+
spec.add_runtime_dependency 'capybara', '~> 2.2.0'
|
30
31
|
end
|
data/lib/capybara-extensions.rb
CHANGED
@@ -18,7 +18,7 @@ module Capybara::DSL
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Capybara::Session
|
21
|
-
CapybaraExtensions
|
21
|
+
CapybaraExtensions.extension_methods.each do |method|
|
22
22
|
define_method method do |*args, &block|
|
23
23
|
current_scope.send method, *args, &block
|
24
24
|
end
|
@@ -174,112 +174,112 @@ module CapybaraExtensions::Finders
|
|
174
174
|
|
175
175
|
alias_method :unordered_list, :find_unordered_list
|
176
176
|
|
177
|
-
# Find the first HTML article on the page matching the given arguments.
|
177
|
+
# Find the first HTML article on the page matching the given arguments. If no arguments are supplied, it will find the first article within your current scope.
|
178
178
|
#
|
179
179
|
# @param args [String] text contained within the article sought.
|
180
180
|
# @param args [Object] the object whose article is sought.
|
181
181
|
# @return [Capybara::Element] the found element.
|
182
182
|
#
|
183
|
-
def first_article(args)
|
183
|
+
def first_article(args=nil)
|
184
184
|
first_element('article', args)
|
185
185
|
end
|
186
186
|
|
187
|
-
# Find the first HTML aside on the page matching the given arguments.
|
187
|
+
# Find the first HTML aside on the page matching the given arguments. If no arguments are supplied, it will find the first aside within your current scope.
|
188
188
|
#
|
189
189
|
# @param args [String, Object] if passed a string, the text contained within the aside sought; if passed an object, the object whose aside is sought.
|
190
190
|
# @return [Capybara::Element] the found element.
|
191
191
|
#
|
192
|
-
def first_aside(args)
|
192
|
+
def first_aside(args=nil)
|
193
193
|
first_element('aside', args)
|
194
194
|
end
|
195
195
|
|
196
|
-
# Find the first HTML footer on the page matching the given arguments.
|
196
|
+
# Find the first HTML footer on the page matching the given arguments. If no arguments are supplied, it will find the first footer within your current scope.
|
197
197
|
#
|
198
198
|
# @param args [String, Object] if passed a string, the text contained within the footer sought; if passed an object, the object whose footer is sought.
|
199
199
|
# @return [Capybara::Element] the found element.
|
200
200
|
#
|
201
|
-
def first_footer(args)
|
201
|
+
def first_footer(args=nil)
|
202
202
|
first_element('footer', args)
|
203
203
|
end
|
204
204
|
|
205
|
-
# Find the first HTML form on the page matching the given arguments.
|
205
|
+
# Find the first HTML form on the page matching the given arguments. If no arguments are supplied, it will find the first form within your current scope.
|
206
206
|
#
|
207
207
|
# @param args [String, Object] if passed a string, the text contained within the form sought; if passed an object, the object whose form is sought.
|
208
208
|
# @return [Capybara::Element] the found element.
|
209
209
|
#
|
210
|
-
def first_form(args)
|
210
|
+
def first_form(args=nil)
|
211
211
|
first_element('form', args)
|
212
212
|
end
|
213
213
|
|
214
|
-
# Find the first HTML header on the page matching the given arguments.
|
214
|
+
# Find the first HTML header on the page matching the given arguments. If no arguments are supplied, it will find the first header within your current scope.
|
215
215
|
#
|
216
216
|
# @param args [String, Object] if passed a string, the text contained within the header sought; if passed an object, the object whose header is sought.
|
217
217
|
# @return [Capybara::Element] the found element.
|
218
218
|
#
|
219
|
-
def first_header(args)
|
219
|
+
def first_header(args=nil)
|
220
220
|
first_element('header', args)
|
221
221
|
end
|
222
222
|
|
223
|
-
# Find the first HTML nav on the page matching the given arguments.
|
223
|
+
# Find the first HTML nav on the page matching the given arguments. If no arguments are supplied, it will find the first nav within your current scope.
|
224
224
|
#
|
225
225
|
# @param args [String, Object] if passed a string, the text contained within the nav sought; if passed an object, the object whose nav is sought.
|
226
226
|
# @return [Capybara::Element] the found element.
|
227
227
|
#
|
228
|
-
def first_navigation(args)
|
228
|
+
def first_navigation(args=nil)
|
229
229
|
first_element('nav', args)
|
230
230
|
end
|
231
231
|
|
232
|
-
# Find the first HTML ol on the page matching the given arguments.
|
232
|
+
# Find the first HTML ol on the page matching the given arguments. If no arguments are supplied, it will find the first ol within your current scope.
|
233
233
|
#
|
234
234
|
# @param args [String, Object] if passed a string, the text contained within the ol sought; if passed an object, the object whose ol is sought.
|
235
235
|
# @return [Capybara::Element] the found element.
|
236
236
|
#
|
237
|
-
def first_ordered_list(args)
|
237
|
+
def first_ordered_list(args=nil)
|
238
238
|
first_element('ol', args)
|
239
239
|
end
|
240
240
|
|
241
|
-
# Find the first HTML p on the page matching the given arguments.
|
241
|
+
# Find the first HTML p on the page matching the given arguments. If no arguments are supplied, it will find the first p within your current scope.
|
242
242
|
#
|
243
243
|
# @param args [String, Object] if passed a string, the text contained within the p sought; if passed an object, the object whose p is sought.
|
244
244
|
# @return [Capybara::Element] the found element.
|
245
245
|
#
|
246
|
-
def first_paragraph(args)
|
246
|
+
def first_paragraph(args=nil)
|
247
247
|
first_element('p', args)
|
248
248
|
end
|
249
249
|
|
250
|
-
# Find the first HTML tr on the page matching the given arguments.
|
250
|
+
# Find the first HTML tr on the page matching the given arguments. If no arguments are supplied, it will find the first tr within your current scope.
|
251
251
|
#
|
252
252
|
# @param args [String, Object] if passed a string, the text contained within the tr sought; if passed an object, the object whose tr is sought.
|
253
253
|
# @return [Capybara::Element] the found element.
|
254
254
|
#
|
255
|
-
def first_row(args)
|
255
|
+
def first_row(args=nil)
|
256
256
|
first_element('tr', args)
|
257
257
|
end
|
258
258
|
|
259
|
-
# Find the first HTML section on the page matching the given arguments.
|
259
|
+
# Find the first HTML section on the page matching the given arguments. If no arguments are supplied, it will find the first section within your current scope.
|
260
260
|
#
|
261
261
|
# @param args [String, Object] if passed a string, the text contained within the section sought; if passed an object, the object whose section is sought.
|
262
262
|
# @return [Capybara::Element] the found element.
|
263
263
|
#
|
264
|
-
def first_section(args)
|
264
|
+
def first_section(args=nil)
|
265
265
|
first_element('section', args)
|
266
266
|
end
|
267
267
|
|
268
|
-
# Find the first HTML table on the page matching the given arguments.
|
268
|
+
# Find the first HTML table on the page matching the given arguments. If no arguments are supplied, it will find the first table within your current scope.
|
269
269
|
#
|
270
270
|
# @param args [String, Object] if passed a string, the text contained within the table sought; if passed an object, the object whose table is sought.
|
271
271
|
# @return [Capybara::Element] the found element.
|
272
272
|
#
|
273
|
-
def first_table(args)
|
273
|
+
def first_table(args=nil)
|
274
274
|
first_element('table', args)
|
275
275
|
end
|
276
276
|
|
277
|
-
# Find the first HTML ul on the page matching the given arguments.
|
277
|
+
# Find the first HTML ul on the page matching the given arguments. If no arguments are supplied, it will find the first unordered list within your current scope.
|
278
278
|
#
|
279
279
|
# @param args [String, Object] if passed a string, the text contained within the ul sought; if passed an object, the object whose ul is sought.
|
280
280
|
# @return [Capybara::Element] the found element.
|
281
281
|
#
|
282
|
-
def first_unordered_list(args)
|
282
|
+
def first_unordered_list(args=nil)
|
283
283
|
first_element('ul', args)
|
284
284
|
end
|
285
285
|
|
@@ -289,16 +289,16 @@ module CapybaraExtensions::Finders
|
|
289
289
|
# @return [Capybara::Element] the found element.
|
290
290
|
#
|
291
291
|
def list_item_number(number)
|
292
|
-
|
292
|
+
find_element_by_number('li', number)
|
293
293
|
end
|
294
294
|
|
295
|
-
# When scoped to a table, find the first HTML tr on the page matching the given arguments.
|
295
|
+
# When scoped to a table, find the first HTML tr on the page matching the given arguments. If passed a negative number, it will find the first tr from the bottom of the table (so row_number(-1) finds the last row in the table).
|
296
296
|
#
|
297
297
|
# @param number [Integer] the nth tr element sought
|
298
298
|
# @return [Capybara::Element] the found element.
|
299
299
|
#
|
300
300
|
def row_number(number)
|
301
|
-
|
301
|
+
find_element_by_number('tr', number)
|
302
302
|
end
|
303
303
|
|
304
304
|
private
|
@@ -318,17 +318,31 @@ module CapybaraExtensions::Finders
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
# Find an element by it's nth occurrence
|
322
|
+
#
|
323
|
+
# @param element [String] the HTML tag for the element
|
324
|
+
#
|
325
|
+
def find_element_by_number(tag, number)
|
326
|
+
elements = all(tag)
|
327
|
+
number = number.to_i
|
328
|
+
element_number = number < 0 ? ((elements.length + 1) + number) : number
|
329
|
+
elements[element_number - 1]
|
330
|
+
end
|
331
|
+
|
332
|
+
|
321
333
|
# Find the first element on the page matching the given arguments.
|
322
334
|
#
|
323
|
-
# @param args [String, Object] if passed a string, the text contained within the element sought; if passed an object, the object whose element is sought.
|
335
|
+
# @param args [String, Object] if passed a string as args, returns the text contained within the element sought; if passed an object, returns the object whose element is sought.
|
324
336
|
# @return [Capybara::Element] the found element.
|
325
337
|
#
|
326
|
-
def first_element(tag, args)
|
327
|
-
if String === args
|
338
|
+
def first_element(tag, args=nil)
|
339
|
+
if args && String === args
|
328
340
|
first(tag, text: args)
|
329
|
-
|
341
|
+
elsif args
|
330
342
|
klass = args.class.to_s.downcase
|
331
343
|
first("#{tag}##{klass}_#{args.id}", "#{tag}.#{klass}")
|
344
|
+
else
|
345
|
+
first("#{tag}")
|
332
346
|
end
|
333
347
|
end
|
334
348
|
end
|
data/test/finders_test.rb
CHANGED
@@ -3,8 +3,12 @@ require 'test_helper'
|
|
3
3
|
describe '.string' do
|
4
4
|
let(:post) { Post.new(3) }
|
5
5
|
let(:string) { Capybara.string TestString }
|
6
|
-
|
6
|
+
|
7
|
+
let(:first_occurrence) { 'John Doe' }
|
8
|
+
let(:last_occurrence) { 'Jane Doe' }
|
9
|
+
|
7
10
|
let(:multiple) { 'Jane Doe' }
|
11
|
+
let(:unique) { 'John Doe' }
|
8
12
|
|
9
13
|
# Finders
|
10
14
|
# article
|
@@ -30,6 +34,11 @@ describe '.string' do
|
|
30
34
|
string.first_article(multiple).text.must_have_content multiple
|
31
35
|
string.first_article(multiple).text.wont_have_content unique
|
32
36
|
end
|
37
|
+
|
38
|
+
it 'should find the first article when no args are passed in' do
|
39
|
+
string.first_article.must_have_content first_occurrence
|
40
|
+
string.first_article.wont_have_content last_occurrence
|
41
|
+
end
|
33
42
|
end
|
34
43
|
|
35
44
|
|
@@ -52,9 +61,16 @@ describe '.string' do
|
|
52
61
|
end
|
53
62
|
|
54
63
|
describe '#list_item_number' do
|
64
|
+
let(:ul) { string.find_unordered_list('foo') }
|
65
|
+
|
55
66
|
it 'return the list item of the number passed in to an ol' do
|
56
|
-
|
57
|
-
|
67
|
+
ul.list_item_number(2).must_have_content 'bar'
|
68
|
+
ul.list_item_number(2).wont_have_content 'foo'
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns the list item fo the negative number passed in to an ol' do
|
72
|
+
ul.list_item_number(-1).must_have_content 'bar'
|
73
|
+
ul.list_item_number(-3).must_have_content 'foo'
|
58
74
|
end
|
59
75
|
end
|
60
76
|
|
@@ -81,6 +97,11 @@ describe '.string' do
|
|
81
97
|
string.first_ordered_list(multiple).text.must_have_content multiple
|
82
98
|
string.first_ordered_list(multiple).text.wont_have_content unique
|
83
99
|
end
|
100
|
+
|
101
|
+
it 'should find the first ordered list when no args are passed in' do
|
102
|
+
string.first_ordered_list.must_have_content first_occurrence
|
103
|
+
string.first_ordered_list.wont_have_content last_occurrence
|
104
|
+
end
|
84
105
|
end
|
85
106
|
|
86
107
|
# ul
|
@@ -106,6 +127,11 @@ describe '.string' do
|
|
106
127
|
string.first_unordered_list(multiple).text.must_have_content multiple
|
107
128
|
string.first_unordered_list(multiple).text.wont_have_content unique
|
108
129
|
end
|
130
|
+
|
131
|
+
it 'finds the first unordered list when no args are passed in' do
|
132
|
+
string.first_unordered_list.must_have_content first_occurrence
|
133
|
+
string.first_unordered_list.wont_have_content last_occurrence
|
134
|
+
end
|
109
135
|
end
|
110
136
|
|
111
137
|
# tr
|
@@ -127,18 +153,33 @@ describe '.string' do
|
|
127
153
|
end
|
128
154
|
|
129
155
|
describe '#first_row' do
|
130
|
-
it 'finds the first
|
156
|
+
it 'finds the first row when passed a non-unique string' do
|
131
157
|
string.first_row(multiple).text.must_have_content multiple
|
132
158
|
string.first_row(multiple).text.wont_have_content unique
|
133
159
|
end
|
160
|
+
|
161
|
+
it 'should find the first row when no args are passed in' do
|
162
|
+
string.first_row.must_have_content 'Author'
|
163
|
+
string.first_row.wont_have_content first_occurrence
|
164
|
+
string.first_row.wont_have_content last_occurrence
|
165
|
+
end
|
134
166
|
end
|
135
167
|
|
136
168
|
describe '#row_number' do
|
169
|
+
let(:tbody) { string.find_table('Jane Doe').find('tbody') }
|
170
|
+
|
137
171
|
it 'returns the row of the number passed in when scoped to a table' do
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
172
|
+
tbody.row_number(1).text.must_have_content 'The first post title'
|
173
|
+
tbody.row_number(1).text.wont_have_content 'The second post title'
|
174
|
+
tbody.row_number(2).text.must_have_content 'The second post title'
|
175
|
+
tbody.row_number(2).text.wont_have_content 'The first post title'
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'returns the row from the end of the table when passed a negative number' do
|
179
|
+
tbody.row_number(-1).text.must_have_content 'The second post title'
|
180
|
+
tbody.row_number(-1).text.wont_have_content 'The first post title'
|
181
|
+
tbody.row_number(-2).text.must_have_content 'The first post title'
|
182
|
+
tbody.row_number(-2).text.wont_have_content 'The second post title'
|
142
183
|
end
|
143
184
|
end
|
144
185
|
|
@@ -165,6 +206,11 @@ describe '.string' do
|
|
165
206
|
string.first_paragraph(multiple).text.must_have_content multiple
|
166
207
|
string.first_paragraph(multiple).text.wont_have_content unique
|
167
208
|
end
|
209
|
+
|
210
|
+
it 'should find the first paragraph when no args are passed in' do
|
211
|
+
string.first_paragraph.must_have_content first_occurrence
|
212
|
+
string.first_paragraph.wont_have_content last_occurrence
|
213
|
+
end
|
168
214
|
end
|
169
215
|
|
170
216
|
# table
|
@@ -193,6 +239,11 @@ describe '.string' do
|
|
193
239
|
string.first_table(multiple).text.must_have_content multiple
|
194
240
|
string.first_table(multiple).text.wont_have_content unique
|
195
241
|
end
|
242
|
+
|
243
|
+
it 'finds the first table when no args are passed in' do
|
244
|
+
string.first_table.must_have_content first_occurrence
|
245
|
+
string.first_table.wont_have_content last_occurrence
|
246
|
+
end
|
196
247
|
end
|
197
248
|
|
198
249
|
|
@@ -219,6 +270,11 @@ describe '.string' do
|
|
219
270
|
string.first_navigation(multiple).text.must_have_content multiple
|
220
271
|
string.first_navigation(multiple).text.wont_have_content unique
|
221
272
|
end
|
273
|
+
|
274
|
+
it 'should find the first navigation when no args are passed in' do
|
275
|
+
string.first_navigation.must_have_content first_occurrence
|
276
|
+
string.first_navigation.wont_have_content last_occurrence
|
277
|
+
end
|
222
278
|
end
|
223
279
|
|
224
280
|
# section
|
@@ -239,6 +295,18 @@ describe '.string' do
|
|
239
295
|
end
|
240
296
|
end
|
241
297
|
|
298
|
+
describe '#first_section' do
|
299
|
+
it 'finds the first section when passed a non-unique string' do
|
300
|
+
string.first_header(multiple).text.must_have_content multiple
|
301
|
+
string.first_header(multiple).text.wont_have_content unique
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'finds the first section when no args are passed in' do
|
305
|
+
string.first_section.must_have_content first_occurrence
|
306
|
+
string.first_section.wont_have_content last_occurrence
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
242
310
|
# header
|
243
311
|
#
|
244
312
|
describe '#header' do
|
@@ -262,6 +330,11 @@ describe '.string' do
|
|
262
330
|
string.first_header(multiple).text.must_have_content multiple
|
263
331
|
string.first_header(multiple).text.wont_have_content unique
|
264
332
|
end
|
333
|
+
|
334
|
+
it 'should find the first header when no args are passed in' do
|
335
|
+
string.first_footer.must_have_content first_occurrence
|
336
|
+
string.first_footer.wont_have_content last_occurrence
|
337
|
+
end
|
265
338
|
end
|
266
339
|
|
267
340
|
# footer
|
@@ -287,6 +360,11 @@ describe '.string' do
|
|
287
360
|
string.first_footer(multiple).text.must_have_content multiple
|
288
361
|
string.first_footer(multiple).text.wont_have_content unique
|
289
362
|
end
|
363
|
+
|
364
|
+
it 'should find the first footer when no args are passed in' do
|
365
|
+
string.first_footer.must_have_content first_occurrence
|
366
|
+
string.first_footer.wont_have_content last_occurrence
|
367
|
+
end
|
290
368
|
end
|
291
369
|
|
292
370
|
# aside
|
@@ -312,6 +390,11 @@ describe '.string' do
|
|
312
390
|
string.first_aside(multiple).text.must_have_content multiple
|
313
391
|
string.first_aside(multiple).text.wont_have_content unique
|
314
392
|
end
|
393
|
+
|
394
|
+
it 'should find the first aside when no args are passed in' do
|
395
|
+
string.first_aside.must_have_content first_occurrence
|
396
|
+
string.first_aside.wont_have_content last_occurrence
|
397
|
+
end
|
315
398
|
end
|
316
399
|
|
317
400
|
# form
|
@@ -337,6 +420,11 @@ describe '.string' do
|
|
337
420
|
string.first_form(multiple).text.must_have_content multiple
|
338
421
|
string.first_form(multiple).text.wont_have_content unique
|
339
422
|
end
|
423
|
+
|
424
|
+
it 'should find the first form when no args are passed in' do
|
425
|
+
string.first_form.must_have_content first_occurrence
|
426
|
+
string.first_form.wont_have_content last_occurrence
|
427
|
+
end
|
340
428
|
end
|
341
429
|
|
342
430
|
# image
|
data/test/string.rb
CHANGED
@@ -36,32 +36,26 @@ TestString = <<-STRING
|
|
36
36
|
</tr>
|
37
37
|
</thead>
|
38
38
|
<tbody>
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
39
|
+
<tr class="post" id="post_1">
|
40
|
+
<td>Jane Doe</td>
|
41
|
+
<td>The first post title</td>
|
42
|
+
<td>Suspendisse id purus quis augue consequat varius ut eget diam. Donec ut lacus vestibulum, porttitor nulla porta, convallis ligula. Nunc sodales venenatis sapien sit amet consequat.</td>
|
43
|
+
<td><a href="/posts/1">Show</a></td>
|
44
|
+
<td><a href="/posts/1/edit">Edit</a></td>
|
45
|
+
<td><a data-confirm="Are you sure?" data-method="delete" href="/posts/1" rel="nofollow">Destroy</a></td>
|
46
|
+
</tr>
|
47
|
+
<tr class="post" id="post_2">
|
48
|
+
<td>Jane Doe</td>
|
49
|
+
<td>The second post title</td>
|
50
|
+
<td>Donec iaculis ultricies orci id consequat. Etiam varius dignissim tincidunt. Sed in lacinia augue. Proin ullamcorper quam at tincidunt consectetur.</td>
|
51
|
+
<td><a href="/posts/2">Show</a></td>
|
52
|
+
<td><a href="/posts/2/edit">Edit</a></td>
|
53
|
+
<td><a data-confirm="Are you sure?" data-method="delete" href="/posts/2" rel="nofollow">Destroy</a></td>
|
54
|
+
</tr>
|
55
55
|
</tbody>
|
56
56
|
</table>
|
57
57
|
|
58
58
|
|
59
|
-
<ul>
|
60
|
-
<li class='post' id='post_3'>foo</li>
|
61
|
-
<li class='post' id='post_2'>bar</li>
|
62
|
-
<li class='post' id='post_1'>bar</li>
|
63
|
-
</ul>
|
64
|
-
|
65
59
|
|
66
60
|
<ul class='posts' id='post_3'>
|
67
61
|
John Doe
|
@@ -75,6 +69,13 @@ TestString = <<-STRING
|
|
75
69
|
Jane Doe
|
76
70
|
</ul>
|
77
71
|
|
72
|
+
<ul>
|
73
|
+
<li class='post' id='post_3'>foo</li>
|
74
|
+
<li class='post' id='post_2'>bar</li>
|
75
|
+
<li class='post' id='post_1'>bar</li>
|
76
|
+
</ul>
|
77
|
+
|
78
|
+
|
78
79
|
|
79
80
|
<ol class='posts' id='post_3'>
|
80
81
|
John Doe
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Dupuis Jr.
|
@@ -9,134 +9,148 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - ~>
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.3'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - ~>
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.3'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: byebug
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: capybara_minitest_spec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: m
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.3.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 1.3.2
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: minitest
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
73
87
|
requirements:
|
74
|
-
- - <
|
88
|
+
- - "<"
|
75
89
|
- !ruby/object:Gem::Version
|
76
90
|
version: '5.0'
|
77
91
|
type: :development
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
|
-
- - <
|
95
|
+
- - "<"
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '5.0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: minitest-reporters
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
|
-
- - ~>
|
102
|
+
- - "~>"
|
89
103
|
- !ruby/object:Gem::Version
|
90
104
|
version: 0.14.21
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- - ~>
|
109
|
+
- - "~>"
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: 0.14.21
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rake
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
|
-
- -
|
116
|
+
- - ">="
|
103
117
|
- !ruby/object:Gem::Version
|
104
118
|
version: '0'
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
|
-
- -
|
123
|
+
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: yard
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
|
-
- -
|
130
|
+
- - ">="
|
117
131
|
- !ruby/object:Gem::Version
|
118
132
|
version: '0'
|
119
133
|
type: :development
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
|
-
- -
|
137
|
+
- - ">="
|
124
138
|
- !ruby/object:Gem::Version
|
125
139
|
version: '0'
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: capybara
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
129
143
|
requirements:
|
130
|
-
- - ~>
|
144
|
+
- - "~>"
|
131
145
|
- !ruby/object:Gem::Version
|
132
|
-
version: 2.
|
146
|
+
version: 2.2.0
|
133
147
|
type: :runtime
|
134
148
|
prerelease: false
|
135
149
|
version_requirements: !ruby/object:Gem::Requirement
|
136
150
|
requirements:
|
137
|
-
- - ~>
|
151
|
+
- - "~>"
|
138
152
|
- !ruby/object:Gem::Version
|
139
|
-
version: 2.
|
153
|
+
version: 2.2.0
|
140
154
|
description: Complements Capybara with additional finders and matchers.
|
141
155
|
email:
|
142
156
|
- michael.dupuis@dockyard.com
|
@@ -145,8 +159,9 @@ executables: []
|
|
145
159
|
extensions: []
|
146
160
|
extra_rdoc_files: []
|
147
161
|
files:
|
148
|
-
- .gitignore
|
149
|
-
- .travis.yml
|
162
|
+
- ".gitignore"
|
163
|
+
- ".travis.yml"
|
164
|
+
- CHANGELOG.md
|
150
165
|
- CONTRIBUTING.md
|
151
166
|
- Gemfile
|
152
167
|
- LICENSE.txt
|
@@ -172,17 +187,17 @@ require_paths:
|
|
172
187
|
- lib
|
173
188
|
required_ruby_version: !ruby/object:Gem::Requirement
|
174
189
|
requirements:
|
175
|
-
- -
|
190
|
+
- - ">="
|
176
191
|
- !ruby/object:Gem::Version
|
177
192
|
version: '0'
|
178
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
194
|
requirements:
|
180
|
-
- -
|
195
|
+
- - ">="
|
181
196
|
- !ruby/object:Gem::Version
|
182
197
|
version: '0'
|
183
198
|
requirements: []
|
184
199
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.0
|
200
|
+
rubygems_version: 2.2.0
|
186
201
|
signing_key:
|
187
202
|
specification_version: 4
|
188
203
|
summary: Capybara has an intuitive API which mimics the language of an actual user.
|