toothbrush 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -1,6 +1,12 @@
1
1
  module Toothbrush
2
2
  module Helpers
3
- def ensure_table(table_selector, header, content)
3
+ def ensure_table(table_selector, header_or_content, content = nil)
4
+ if content.nil?
5
+ return _ensure_table(table_selector, header_or_content)
6
+ else
7
+ header = header_or_content
8
+ end
9
+
4
10
  columns = {}
5
11
  header.each do |title|
6
12
  n = 1
@@ -11,7 +17,14 @@ module Toothbrush
11
17
  n += 1
12
18
  end
13
19
  rescue Capybara::ElementNotFound
14
- break
20
+ begin
21
+ within("#{table_selector} tr th:nth-child(#{n})") do
22
+ columns[title] = n if page.has_content?(title)
23
+ n += 1
24
+ end
25
+ rescue Capybara::ElementNotFound
26
+ break
27
+ end
15
28
  end
16
29
  end
17
30
  end
@@ -20,8 +33,27 @@ module Toothbrush
20
33
 
21
34
  content.each_with_index do |celulas, index|
22
35
  celulas.each_with_index do |value, td_index|
23
- within("#{table_selector} tbody tr:nth-child(#{index+1}) td:nth-child(#{columns[header[td_index]]})") do
24
- page.should have_content(value)
36
+ begin
37
+ within("#{table_selector} tbody tr:nth-child(#{index+1}) td:nth-child(#{columns[header[td_index]]})") do
38
+ page.should have_content(value)
39
+ end
40
+ rescue Capybara::ElementNotFound
41
+ within("#{table_selector} tr:nth-child(#{index+2}) td:nth-child(#{columns[header[td_index]]})") do
42
+ page.should have_content(value)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def _ensure_table(selector, content)
52
+ column_count = content[0].count
53
+ content.each_with_index do |row, row_index|
54
+ row.each_with_index do |cell_data, cell_index|
55
+ within("#{selector} tr:nth-child(#{row_index + 1}) td:nth-child(#{cell_index + 1})") do
56
+ page.should have_content cell_data
25
57
  end
26
58
  end
27
59
  end
@@ -46,3 +46,33 @@
46
46
  </tr>
47
47
  </tbody>
48
48
  </table>
49
+
50
+ <table id='without-thead-tbody'>
51
+ <tr>
52
+ <th>1</th>
53
+ <th>2</th>
54
+ </tr>
55
+ <tr>
56
+ <td>3</td>
57
+ <td>4</td>
58
+ </tr>
59
+ <tr>
60
+ <td>5</td>
61
+ <td>6</td>
62
+ </tr>
63
+ </table>
64
+
65
+ <table id='without-th'>
66
+ <tr>
67
+ <td>1</td>
68
+ <td>2</td>
69
+ </tr>
70
+ <tr>
71
+ <td>3</td>
72
+ <td>4</td>
73
+ </tr>
74
+ <tr>
75
+ <td>5</td>
76
+ <td>6</td>
77
+ </tr>
78
+ </table>
@@ -28,5 +28,19 @@ describe "Toothbrush" do
28
28
  }.to raise_error(RSpec::Expectations::ExpectationNotMetError,
29
29
  'expected #has_content?("1") to return true, got false')
30
30
  end
31
+
32
+ it 'supports tables without <thead> and <tbody>' do
33
+ ensure_table '#without-thead-tbody',
34
+ %w( 1 2),
35
+ [%w(3 4),
36
+ %w(5 6)]
37
+ end
38
+
39
+ it 'supports tables without <th>' do
40
+ ensure_table '#without-th',
41
+ [%w(1 2),
42
+ %w(3 4),
43
+ %w(5 6)]
44
+ end
31
45
  end
32
46
  end
data/toothbrush.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "toothbrush"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rodrigo Manh\u{e3}es"]
12
- s.date = "2012-05-15"
12
+ s.date = "2012-06-03"
13
13
  s.description = "Useful stuff for testing with Capybara"
14
14
  s.email = "rmanhaes@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -55,6 +55,18 @@ Gem::Specification.new do |s|
55
55
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
56
56
  s.add_development_dependency(%q<simplecov>, [">= 0"])
57
57
  s.add_development_dependency(%q<sinatra>, [">= 0"])
58
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
59
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
61
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
62
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
63
+ s.add_development_dependency(%q<sinatra>, [">= 0"])
64
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
65
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
66
+ s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
67
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
68
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
69
+ s.add_development_dependency(%q<sinatra>, [">= 0"])
58
70
  s.add_runtime_dependency(%q<capybara>, ["~> 1.0"])
59
71
  else
60
72
  s.add_dependency(%q<toothbrush>, [">= 0"])
@@ -70,6 +82,18 @@ Gem::Specification.new do |s|
70
82
  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
71
83
  s.add_dependency(%q<simplecov>, [">= 0"])
72
84
  s.add_dependency(%q<sinatra>, [">= 0"])
85
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
86
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
87
+ s.add_dependency(%q<bundler>, ["~> 1.1.0"])
88
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
89
+ s.add_dependency(%q<simplecov>, [">= 0"])
90
+ s.add_dependency(%q<sinatra>, [">= 0"])
91
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
92
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
93
+ s.add_dependency(%q<bundler>, ["~> 1.1.0"])
94
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
95
+ s.add_dependency(%q<simplecov>, [">= 0"])
96
+ s.add_dependency(%q<sinatra>, [">= 0"])
73
97
  s.add_dependency(%q<capybara>, ["~> 1.0"])
74
98
  end
75
99
  else
@@ -86,6 +110,18 @@ Gem::Specification.new do |s|
86
110
  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
87
111
  s.add_dependency(%q<simplecov>, [">= 0"])
88
112
  s.add_dependency(%q<sinatra>, [">= 0"])
113
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
114
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
115
+ s.add_dependency(%q<bundler>, ["~> 1.1.0"])
116
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
117
+ s.add_dependency(%q<simplecov>, [">= 0"])
118
+ s.add_dependency(%q<sinatra>, [">= 0"])
119
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
120
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
121
+ s.add_dependency(%q<bundler>, ["~> 1.1.0"])
122
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
123
+ s.add_dependency(%q<simplecov>, [">= 0"])
124
+ s.add_dependency(%q<sinatra>, [">= 0"])
89
125
  s.add_dependency(%q<capybara>, ["~> 1.0"])
90
126
  end
91
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toothbrush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000 Z
12
+ date: 2012-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: toothbrush
@@ -219,6 +219,198 @@ dependencies:
219
219
  - - ! '>='
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: rspec
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ~>
228
+ - !ruby/object:Gem::Version
229
+ version: 2.8.0
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: 2.8.0
238
+ - !ruby/object:Gem::Dependency
239
+ name: rdoc
240
+ requirement: !ruby/object:Gem::Requirement
241
+ none: false
242
+ requirements:
243
+ - - ~>
244
+ - !ruby/object:Gem::Version
245
+ version: '3.12'
246
+ type: :development
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ~>
252
+ - !ruby/object:Gem::Version
253
+ version: '3.12'
254
+ - !ruby/object:Gem::Dependency
255
+ name: bundler
256
+ requirement: !ruby/object:Gem::Requirement
257
+ none: false
258
+ requirements:
259
+ - - ~>
260
+ - !ruby/object:Gem::Version
261
+ version: 1.1.0
262
+ type: :development
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ~>
268
+ - !ruby/object:Gem::Version
269
+ version: 1.1.0
270
+ - !ruby/object:Gem::Dependency
271
+ name: jeweler
272
+ requirement: !ruby/object:Gem::Requirement
273
+ none: false
274
+ requirements:
275
+ - - ~>
276
+ - !ruby/object:Gem::Version
277
+ version: 1.8.3
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ none: false
282
+ requirements:
283
+ - - ~>
284
+ - !ruby/object:Gem::Version
285
+ version: 1.8.3
286
+ - !ruby/object:Gem::Dependency
287
+ name: simplecov
288
+ requirement: !ruby/object:Gem::Requirement
289
+ none: false
290
+ requirements:
291
+ - - ! '>='
292
+ - !ruby/object:Gem::Version
293
+ version: '0'
294
+ type: :development
295
+ prerelease: false
296
+ version_requirements: !ruby/object:Gem::Requirement
297
+ none: false
298
+ requirements:
299
+ - - ! '>='
300
+ - !ruby/object:Gem::Version
301
+ version: '0'
302
+ - !ruby/object:Gem::Dependency
303
+ name: sinatra
304
+ requirement: !ruby/object:Gem::Requirement
305
+ none: false
306
+ requirements:
307
+ - - ! '>='
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ type: :development
311
+ prerelease: false
312
+ version_requirements: !ruby/object:Gem::Requirement
313
+ none: false
314
+ requirements:
315
+ - - ! '>='
316
+ - !ruby/object:Gem::Version
317
+ version: '0'
318
+ - !ruby/object:Gem::Dependency
319
+ name: rspec
320
+ requirement: !ruby/object:Gem::Requirement
321
+ none: false
322
+ requirements:
323
+ - - ~>
324
+ - !ruby/object:Gem::Version
325
+ version: 2.8.0
326
+ type: :development
327
+ prerelease: false
328
+ version_requirements: !ruby/object:Gem::Requirement
329
+ none: false
330
+ requirements:
331
+ - - ~>
332
+ - !ruby/object:Gem::Version
333
+ version: 2.8.0
334
+ - !ruby/object:Gem::Dependency
335
+ name: rdoc
336
+ requirement: !ruby/object:Gem::Requirement
337
+ none: false
338
+ requirements:
339
+ - - ~>
340
+ - !ruby/object:Gem::Version
341
+ version: '3.12'
342
+ type: :development
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ none: false
346
+ requirements:
347
+ - - ~>
348
+ - !ruby/object:Gem::Version
349
+ version: '3.12'
350
+ - !ruby/object:Gem::Dependency
351
+ name: bundler
352
+ requirement: !ruby/object:Gem::Requirement
353
+ none: false
354
+ requirements:
355
+ - - ~>
356
+ - !ruby/object:Gem::Version
357
+ version: 1.1.0
358
+ type: :development
359
+ prerelease: false
360
+ version_requirements: !ruby/object:Gem::Requirement
361
+ none: false
362
+ requirements:
363
+ - - ~>
364
+ - !ruby/object:Gem::Version
365
+ version: 1.1.0
366
+ - !ruby/object:Gem::Dependency
367
+ name: jeweler
368
+ requirement: !ruby/object:Gem::Requirement
369
+ none: false
370
+ requirements:
371
+ - - ~>
372
+ - !ruby/object:Gem::Version
373
+ version: 1.8.3
374
+ type: :development
375
+ prerelease: false
376
+ version_requirements: !ruby/object:Gem::Requirement
377
+ none: false
378
+ requirements:
379
+ - - ~>
380
+ - !ruby/object:Gem::Version
381
+ version: 1.8.3
382
+ - !ruby/object:Gem::Dependency
383
+ name: simplecov
384
+ requirement: !ruby/object:Gem::Requirement
385
+ none: false
386
+ requirements:
387
+ - - ! '>='
388
+ - !ruby/object:Gem::Version
389
+ version: '0'
390
+ type: :development
391
+ prerelease: false
392
+ version_requirements: !ruby/object:Gem::Requirement
393
+ none: false
394
+ requirements:
395
+ - - ! '>='
396
+ - !ruby/object:Gem::Version
397
+ version: '0'
398
+ - !ruby/object:Gem::Dependency
399
+ name: sinatra
400
+ requirement: !ruby/object:Gem::Requirement
401
+ none: false
402
+ requirements:
403
+ - - ! '>='
404
+ - !ruby/object:Gem::Version
405
+ version: '0'
406
+ type: :development
407
+ prerelease: false
408
+ version_requirements: !ruby/object:Gem::Requirement
409
+ none: false
410
+ requirements:
411
+ - - ! '>='
412
+ - !ruby/object:Gem::Version
413
+ version: '0'
222
414
  - !ruby/object:Gem::Dependency
223
415
  name: capybara
224
416
  requirement: !ruby/object:Gem::Requirement
@@ -272,7 +464,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
272
464
  version: '0'
273
465
  segments:
274
466
  - 0
275
- hash: 780479681
467
+ hash: 467052125
276
468
  required_rubygems_version: !ruby/object:Gem::Requirement
277
469
  none: false
278
470
  requirements: