toothbrush 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0236cdd0e3cd84517f2172af73e1eb430373dd8
4
- data.tar.gz: 16bbf613fe9f1b22077041dbba1fc482043d2454
3
+ metadata.gz: f5cab23c424716b62f91cc911e5cc791b7996a59
4
+ data.tar.gz: 63dae1dc762876bf9b631d14433b65a51dd47b6f
5
5
  SHA512:
6
- metadata.gz: 3e27a550cef69208428161cccb36ef51d6bac05e8fc7631c2efabdbe70cad113aadd9f0f0eaa69db69026552aa629ee737d291c2609e4b0d6601c53724fae6e5
7
- data.tar.gz: b2ea8d28c73be7673841d675cc6e81de457178b85e8ebbe7ae8548d1f0b54a728afb0f19771e06e4256c8ff83fc7e3dd4be8ca8e9a65b794a7f9b2081597041a
6
+ metadata.gz: 47a187e4cad4dcbcad24ba42af9f5ca50847876a8466375399c77339ade89a4e3773d99b499c497dec263c02778e091eab0ea7dbaf4d2e2348dea7b9fa645b23
7
+ data.tar.gz: 9dc68841bf341c38a27df44c17e8fea4097472b9c7e22b27345153c15d1c45df501502dd4bba3ff0a13e24486949205070ad0298713bc6160cb024453736c859
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format documentation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -4,7 +4,14 @@ require 'text-table'
4
4
  RSpec::Matchers.define :include_table do |selector, *header_content|
5
5
  match do |actual|
6
6
  if header_content.count == 2
7
- expected_header, expected_content = header_content.map(&:clone)
7
+ header_or_content = header_content[0]
8
+ if header_or_content[0].is_a? Array
9
+ expected_content, expected_foot = header_content
10
+ else
11
+ expected_header, expected_content = header_content
12
+ end
13
+ elsif header_content.count == 3
14
+ expected_header, expected_content, expected_foot = header_content.map(&:clone)
8
15
  else
9
16
  expected_header, expected_content = nil, header_content[0].clone
10
17
  end
@@ -21,6 +28,10 @@ RSpec::Matchers.define :include_table do |selector, *header_content|
21
28
  actual.has_selector?("#{selector} tbody")
22
29
  end
23
30
 
31
+ has_tfoot = lambda do
32
+ actual.has_selector?("#{selector} tfoot")
33
+ end
34
+
24
35
  has_header = lambda do
25
36
  has_thead[] || actual.has_selector?("#{selector} tr th")
26
37
  end
@@ -29,6 +40,8 @@ RSpec::Matchers.define :include_table do |selector, *header_content|
29
40
  expected_header && !expected_header.empty?
30
41
  end
31
42
 
43
+ html_foot = lambda { actual.all("#{selector} tfoot tr td").map(&:text) }
44
+
32
45
  html_table_to_array = lambda do
33
46
  if has_thead[]
34
47
  header = actual.all("#{selector} thead tr th").map(&:text)
@@ -50,7 +63,11 @@ RSpec::Matchers.define :include_table do |selector, *header_content|
50
63
  header << '' while header.size < body_size
51
64
  body.unshift(header)
52
65
  end
53
- body.to_table(first_row_is_head: has_header[]).to_s
66
+
67
+ body.push(html_foot[]) if has_tfoot[]
68
+
69
+ body.to_table(first_row_is_head: has_header[],
70
+ last_row_is_foot: has_tfoot[]).to_s
54
71
  end
55
72
 
56
73
  column_equivalence = {}
@@ -105,7 +122,13 @@ RSpec::Matchers.define :include_table do |selector, *header_content|
105
122
  end
106
123
  end
107
124
 
108
- result = check_selector[] && check_header[] && check_content[]
125
+ check_foot = lambda do
126
+ return true unless expected_foot
127
+ return false if expected_foot && !has_tfoot[]
128
+ html_foot[] == expected_foot
129
+ end
130
+
131
+ result = check_selector[] && check_header[] && check_content[] && check_foot[]
109
132
  if !result
110
133
  if !check_selector[]
111
134
  @message = "expected to have selector '#{selector}'"
@@ -115,8 +138,13 @@ RSpec::Matchers.define :include_table do |selector, *header_content|
115
138
  expected_header << '' while expected_header.size < expected_table.first.size
116
139
  expected_table.unshift(expected_header)
117
140
  end
141
+
142
+ expected_table.push(expected_foot) if expected_foot
143
+
118
144
  @message = "expected to include table\n%sbut found\n%s" %
119
- [expected_table.to_table(first_row_is_head: expected_has_header[]),
145
+ [expected_table.to_table(
146
+ first_row_is_head: expected_has_header[],
147
+ last_row_is_foot: !!expected_foot),
120
148
  html_table_to_array[]]
121
149
  end
122
150
  end
@@ -100,3 +100,22 @@
100
100
 
101
101
  <table id='nothing-inside'>
102
102
  </table>
103
+
104
+ <table id='with-tfoot'>
105
+ <tbody>
106
+ <tr>
107
+ <td>1</td>
108
+ <td>2</td>
109
+ </tr>
110
+ <tr>
111
+ <td>3</td>
112
+ <td>4</td>
113
+ </tr>
114
+ </tbody>
115
+ <tfoot>
116
+ <tr>
117
+ <td>5</td>
118
+ <td>6</td>
119
+ </tr>
120
+ </tfoot>
121
+ </table>
@@ -186,4 +186,39 @@ but found
186
186
  ++
187
187
  """)
188
188
  end
189
+
190
+ describe 'supports <tfoot>' do
191
+ it 'passing' do
192
+ expect {
193
+ expect(page).to include_table '#with-tfoot',
194
+ [%w( 1 2 ),
195
+ %w( 3 4 )],
196
+ %w( 5 6 )
197
+ }.to_not raise_error
198
+ end
199
+
200
+ it 'failing' do
201
+ expect {
202
+ expect(page).to include_table '#with-tfoot',
203
+ [%w( 1 2 ),
204
+ %w( 3 4 )],
205
+ %w( 5 7 )
206
+ }.to raise_error(RSpec::Expectations::ExpectationNotMetError,
207
+ """expected to include table
208
+ +---+---+
209
+ | 1 | 2 |
210
+ | 3 | 4 |
211
+ +---+---+
212
+ | 5 | 7 |
213
+ +---+---+
214
+ but found
215
+ +---+---+
216
+ | 1 | 2 |
217
+ | 3 | 4 |
218
+ +---+---+
219
+ | 5 | 6 |
220
+ +---+---+
221
+ """)
222
+ end
223
+ end
189
224
  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.4"
8
+ s.version = "0.1.5"
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 = "2013-02-23"
12
+ s.date = "2014-06-24"
13
13
  s.description = "Useful stuff for testing with Capybara"
14
14
  s.email = "rmanhaes@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toothbrush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Manhães
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-23 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: text-table
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.11.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.11.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sinatra
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: capybara
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Useful stuff for testing with Capybara
@@ -88,8 +88,8 @@ extra_rdoc_files:
88
88
  - LICENSE.txt
89
89
  - README.rdoc
90
90
  files:
91
- - ".document"
92
- - ".rspec"
91
+ - .document
92
+ - .rspec
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.rdoc
@@ -112,17 +112,17 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.2.2
125
+ rubygems_version: 2.0.3
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Useful stuff for testing with Capybara