rails-dom-testing 2.0.3 → 2.2.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.
- checksums.yaml +5 -5
- data/README.md +44 -26
- data/lib/rails/dom/testing/assertions/dom_assertions.rb +82 -18
- data/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb +129 -111
- data/lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb +36 -25
- data/lib/rails/dom/testing/assertions/selector_assertions.rb +287 -233
- data/lib/rails/dom/testing/assertions.rb +5 -8
- data/lib/rails/dom/testing/railtie.rb +14 -0
- data/lib/rails/dom/testing/version.rb +3 -1
- data/lib/rails/dom/testing.rb +52 -0
- data/lib/rails-dom-testing.rb +4 -1
- data/test/dom_assertions_test.rb +169 -6
- data/test/parser_selection_test.rb +75 -0
- data/test/selector_assertions_test.rb +152 -68
- data/test/test_helper.rb +21 -4
- metadata +20 -32
- data/lib/rails/dom/testing/assertions/selector_assertions/count_describable.rb +0 -32
@@ -1,11 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require 'rails/dom/testing/assertions/selector_assertions'
|
4
|
+
require "test_helper"
|
5
5
|
|
6
6
|
class AssertSelectTest < ActiveSupport::TestCase
|
7
7
|
Assertion = Minitest::Assertion
|
8
8
|
|
9
|
+
include DomTestingHelpers
|
9
10
|
include Rails::Dom::Testing::Assertions::SelectorAssertions
|
10
11
|
|
11
12
|
def assert_failure(message, &block)
|
@@ -19,19 +20,19 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
19
20
|
#
|
20
21
|
|
21
22
|
def test_assert_select
|
22
|
-
render_html
|
23
|
+
render_html '<div id="1"></div><div id="2"></div>'
|
23
24
|
assert_select "div", 2
|
24
|
-
assert_failure(/Expected at least 1 element matching
|
25
|
+
assert_failure(/Expected at least 1 element matching "p", found 0/) { assert_select "p" }
|
25
26
|
end
|
26
27
|
|
27
28
|
def test_equality_integer
|
28
|
-
render_html
|
29
|
-
assert_failure(/Expected exactly 3 elements matching
|
30
|
-
assert_failure(/Expected exactly 0 elements matching
|
29
|
+
render_html '<div id="1"></div><div id="2"></div>'
|
30
|
+
assert_failure(/Expected exactly 3 elements matching "div", found 2/) { assert_select "div", 3 }
|
31
|
+
assert_failure(/Expected exactly 0 elements matching "div", found 2/) { assert_select "div", 0 }
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_equality_true_false
|
34
|
-
render_html
|
35
|
+
render_html '<div id="1"></div><div id="2"></div>'
|
35
36
|
assert_nothing_raised { assert_select "div" }
|
36
37
|
assert_raise(Assertion) { assert_select "p" }
|
37
38
|
assert_nothing_raised { assert_select "div", true }
|
@@ -49,21 +50,21 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def test_equality_false_message
|
52
|
-
render_html
|
53
|
-
assert_failure(/Expected exactly 0 elements matching
|
53
|
+
render_html '<div id="1"></div><div id="2"></div>'
|
54
|
+
assert_failure(/Expected exactly 0 elements matching "div", found 2/) { assert_select "div", false }
|
54
55
|
end
|
55
56
|
|
56
57
|
def test_equality_string_and_regexp
|
57
|
-
render_html
|
58
|
+
render_html '<div id="1">foo</div><div id="2">foo</div>'
|
58
59
|
assert_nothing_raised { assert_select "div", "foo" }
|
59
60
|
assert_raise(Assertion) { assert_select "div", "bar" }
|
60
|
-
assert_nothing_raised { assert_select "div", :
|
61
|
-
assert_raise(Assertion) { assert_select "div", :
|
61
|
+
assert_nothing_raised { assert_select "div", text: "foo" }
|
62
|
+
assert_raise(Assertion) { assert_select "div", text: "bar" }
|
62
63
|
assert_nothing_raised { assert_select "div", /(foo|bar)/ }
|
63
64
|
assert_raise(Assertion) { assert_select "div", /foobar/ }
|
64
|
-
assert_nothing_raised { assert_select "div", :
|
65
|
-
assert_raise(Assertion) { assert_select "div", :
|
66
|
-
assert_raise(Assertion) { assert_select "p", :
|
65
|
+
assert_nothing_raised { assert_select "div", text: /(foo|bar)/ }
|
66
|
+
assert_raise(Assertion) { assert_select "div", text: /foobar/ }
|
67
|
+
assert_raise(Assertion) { assert_select "p", text: /foobar/ }
|
67
68
|
end
|
68
69
|
|
69
70
|
def test_equality_of_html
|
@@ -72,57 +73,57 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
72
73
|
html = "<em>\"This is <strong>not</strong> a big problem,\"</em> he said."
|
73
74
|
assert_nothing_raised { assert_select "p", text }
|
74
75
|
assert_raise(Assertion) { assert_select "p", html }
|
75
|
-
assert_nothing_raised { assert_select "p", :html
|
76
|
-
assert_raise(Assertion) { assert_select "p", :
|
76
|
+
assert_nothing_raised { assert_select "p", html: html }
|
77
|
+
assert_raise(Assertion) { assert_select "p", html: text }
|
77
78
|
# No stripping for pre.
|
78
79
|
render_html %Q{<pre>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</pre>}
|
79
80
|
text = "\n\"This is not a big problem,\" he said.\n"
|
80
81
|
html = "\n<em>\"This is <strong>not</strong> a big problem,\"</em> he said.\n"
|
81
82
|
assert_nothing_raised { assert_select "pre", text }
|
82
83
|
assert_raise(Assertion) { assert_select "pre", html }
|
83
|
-
assert_nothing_raised { assert_select "pre", :html
|
84
|
-
assert_raise(Assertion) { assert_select "pre", :
|
84
|
+
assert_nothing_raised { assert_select "pre", html: html }
|
85
|
+
assert_raise(Assertion) { assert_select "pre", html: text }
|
85
86
|
end
|
86
87
|
|
87
88
|
def test_strip_textarea
|
88
|
-
render_html
|
89
|
+
render_html "<textarea>\n\nfoo\n</textarea>"
|
89
90
|
assert_select "textarea", "\nfoo\n"
|
90
|
-
render_html
|
91
|
+
render_html "<textarea>\nfoo</textarea>"
|
91
92
|
assert_select "textarea", "foo"
|
92
93
|
end
|
93
94
|
|
94
95
|
def test_counts
|
95
|
-
render_html
|
96
|
+
render_html '<div id="1">foo</div><div id="2">foo</div>'
|
96
97
|
assert_nothing_raised { assert_select "div", 2 }
|
97
|
-
assert_failure(/Expected exactly 3 elements matching
|
98
|
+
assert_failure(/Expected exactly 3 elements matching "div", found 2/) do
|
98
99
|
assert_select "div", 3
|
99
100
|
end
|
100
101
|
assert_nothing_raised { assert_select "div", 1..2 }
|
101
|
-
assert_failure(/Expected between 3 and 4 elements matching
|
102
|
+
assert_failure(/Expected between 3 and 4 elements matching "div", found 2/) do
|
102
103
|
assert_select "div", 3..4
|
103
104
|
end
|
104
|
-
assert_nothing_raised { assert_select "div", :
|
105
|
-
assert_failure(/Expected exactly 3 elements matching
|
106
|
-
assert_select "div", :
|
105
|
+
assert_nothing_raised { assert_select "div", count: 2 }
|
106
|
+
assert_failure(/Expected exactly 3 elements matching "div", found 2/) do
|
107
|
+
assert_select "div", count: 3
|
107
108
|
end
|
108
|
-
assert_nothing_raised { assert_select "div", :
|
109
|
-
assert_nothing_raised { assert_select "div", :
|
110
|
-
assert_failure(/Expected at least 3 elements matching
|
111
|
-
assert_select "div", :
|
109
|
+
assert_nothing_raised { assert_select "div", minimum: 1 }
|
110
|
+
assert_nothing_raised { assert_select "div", minimum: 2 }
|
111
|
+
assert_failure(/Expected at least 3 elements matching "div", found 2/) do
|
112
|
+
assert_select "div", minimum: 3
|
112
113
|
end
|
113
|
-
assert_nothing_raised { assert_select "div", :
|
114
|
-
assert_nothing_raised { assert_select "div", :
|
115
|
-
assert_failure(/Expected at most 1 element matching
|
116
|
-
assert_select "div", :
|
114
|
+
assert_nothing_raised { assert_select "div", maximum: 2 }
|
115
|
+
assert_nothing_raised { assert_select "div", maximum: 3 }
|
116
|
+
assert_failure(/Expected at most 1 element matching "div", found 2/) do
|
117
|
+
assert_select "div", maximum: 1
|
117
118
|
end
|
118
|
-
assert_nothing_raised { assert_select "div", :
|
119
|
-
assert_failure(/Expected between 3 and 4 elements matching
|
120
|
-
assert_select "div", :
|
119
|
+
assert_nothing_raised { assert_select "div", minimum: 1, maximum: 2 }
|
120
|
+
assert_failure(/Expected between 3 and 4 elements matching "div", found 2/) do
|
121
|
+
assert_select "div", minimum: 3, maximum: 4
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
125
|
def test_substitution_values
|
125
|
-
render_html
|
126
|
+
render_html '<div id="1">foo</div><div id="2">foo</div>'
|
126
127
|
assert_select "div:match('id', ?)", /\d+/ do |elements|
|
127
128
|
assert_equal 2, elements.size
|
128
129
|
end
|
@@ -135,20 +136,40 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
139
|
+
def test_substitution_value_with_quotes
|
140
|
+
render_html '<input placeholder="placeholder with "quotes"" />'
|
141
|
+
assert_select "input[placeholder=?]", 'placeholder with "quotes"'
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_multiple_substitution_values
|
145
|
+
render_html '<input name="foo[12]" value="34">'
|
146
|
+
assert_select ":match('name', ?):match('value', ?)", /\w+\[\d+\]/, /\d+/
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_substitution_values_with_values_other_than_string_or_regexp
|
150
|
+
render_html '<div id="id_string">symbol</div><div id="1">numeric</div>'
|
151
|
+
assert_select "div:match('id', ?)", :id_string do |elements|
|
152
|
+
assert_equal 1, elements.size
|
153
|
+
end
|
154
|
+
assert_select "div:match('id', ?)", 1 do |elements|
|
155
|
+
assert_equal 1, elements.size
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
138
159
|
def test_assert_select_root_html
|
139
|
-
render_html
|
160
|
+
render_html "<a></a>"
|
140
161
|
|
141
|
-
assert_select
|
162
|
+
assert_select "a"
|
142
163
|
end
|
143
164
|
|
144
165
|
def test_assert_select_root_xml
|
145
166
|
render_xml '<rss version="2.0"></rss>'
|
146
167
|
|
147
|
-
assert_select
|
168
|
+
assert_select "rss"
|
148
169
|
end
|
149
170
|
|
150
171
|
def test_nested_assert_select
|
151
|
-
render_html
|
172
|
+
render_html '<div id="1">foo</div><div id="2">foo</div>'
|
152
173
|
assert_select "div" do |elements|
|
153
174
|
assert_equal 2, elements.size
|
154
175
|
assert_select elements, "#1"
|
@@ -166,7 +187,7 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
166
187
|
end
|
167
188
|
end
|
168
189
|
|
169
|
-
assert_failure(/Expected at least 1 element matching
|
190
|
+
assert_failure(/Expected at least 1 element matching "#4", found 0\./) do
|
170
191
|
assert_select "div" do
|
171
192
|
assert_select "#4"
|
172
193
|
end
|
@@ -174,18 +195,18 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
174
195
|
end
|
175
196
|
|
176
197
|
def test_assert_select_text_match
|
177
|
-
render_html
|
198
|
+
render_html '<div id="1"><span>foo</span></div><div id="2"><span>bar</span></div>'
|
178
199
|
assert_select "div" do
|
179
200
|
assert_nothing_raised { assert_select "div", "foo" }
|
180
201
|
assert_nothing_raised { assert_select "div", "bar" }
|
181
202
|
assert_nothing_raised { assert_select "div", /\w*/ }
|
182
|
-
assert_nothing_raised { assert_select "div", :
|
183
|
-
assert_raise(Assertion) { assert_select "div", :
|
184
|
-
assert_nothing_raised { assert_select "div", :
|
185
|
-
assert_nothing_raised { assert_select "div", :
|
186
|
-
assert_nothing_raised { assert_select "div", :
|
187
|
-
assert_nothing_raised { assert_select "div", :
|
188
|
-
assert_raise(Assertion) { assert_select "div", :
|
203
|
+
assert_nothing_raised { assert_select "div", text: /\w*/, count: 2 }
|
204
|
+
assert_raise(Assertion) { assert_select "div", text: "foo", count: 2 }
|
205
|
+
assert_nothing_raised { assert_select "div", html: "<span>bar</span>" }
|
206
|
+
assert_nothing_raised { assert_select "div", html: "<span>bar</span>" }
|
207
|
+
assert_nothing_raised { assert_select "div", html: /\w*/ }
|
208
|
+
assert_nothing_raised { assert_select "div", html: /\w*/, count: 2 }
|
209
|
+
assert_raise(Assertion) { assert_select "div", html: "<span>foo</span>", count: 2 }
|
189
210
|
end
|
190
211
|
end
|
191
212
|
|
@@ -194,13 +215,13 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
194
215
|
#
|
195
216
|
|
196
217
|
def test_css_select
|
197
|
-
render_html
|
218
|
+
render_html '<div id="1"></div><div id="2"></div>'
|
198
219
|
assert_equal 2, css_select("div").size
|
199
220
|
assert_equal 0, css_select("p").size
|
200
221
|
end
|
201
222
|
|
202
223
|
def test_nested_css_select
|
203
|
-
render_html
|
224
|
+
render_html '<div id="1">foo</div><div id="2">foo</div>'
|
204
225
|
assert_select "div:match('id', ?)", /\d+/ do |elements|
|
205
226
|
assert_equal 1, css_select(elements[0], "div").size
|
206
227
|
assert_equal 1, css_select(elements[1], "div").size
|
@@ -209,10 +230,10 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
209
230
|
assert_equal 2, css_select("div").size
|
210
231
|
css_select("div").each do |element|
|
211
232
|
# Testing as a group is one thing
|
212
|
-
|
233
|
+
assert_not css_select("#1,#2").empty?
|
213
234
|
# Testing individually is another
|
214
|
-
|
215
|
-
|
235
|
+
assert_not css_select("#1").empty?
|
236
|
+
assert_not css_select("#2").empty?
|
216
237
|
end
|
217
238
|
end
|
218
239
|
end
|
@@ -233,13 +254,13 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
233
254
|
end
|
234
255
|
|
235
256
|
def test_nested_assert_select_with_match_failure_shows_nice_regex
|
236
|
-
render_html
|
257
|
+
render_html '<div id="1">foo</div>'
|
237
258
|
|
238
259
|
error = assert_raises Minitest::Assertion do
|
239
260
|
assert_select "div:match('id', ?)", /wups/
|
240
261
|
end
|
241
262
|
|
242
|
-
assert_match
|
263
|
+
assert_match "div:match('id', /wups/)", error.message
|
243
264
|
end
|
244
265
|
|
245
266
|
def test_feed_item_encoded
|
@@ -260,12 +281,11 @@ class AssertSelectTest < ActiveSupport::TestCase
|
|
260
281
|
</item>
|
261
282
|
</channel>
|
262
283
|
</rss>
|
263
|
-
EOF
|
284
|
+
EOF
|
264
285
|
|
265
286
|
assert_select "channel item description" do
|
266
|
-
|
267
287
|
assert_select_encoded do
|
268
|
-
assert_select "p", :
|
288
|
+
assert_select "p", count: 2, text: /Test/
|
269
289
|
end
|
270
290
|
|
271
291
|
# Test individually.
|
@@ -287,19 +307,83 @@ EOF
|
|
287
307
|
end
|
288
308
|
end
|
289
309
|
|
310
|
+
def test_feed_item_encoded_with_html_version
|
311
|
+
# https://html.spec.whatwg.org/multipage/parsing.html#an-introduction-to-error-handling-and-strange-cases-in-the-parser
|
312
|
+
# we use these results to assert that we're invoking the expected parser.
|
313
|
+
input = CGI.escapeHTML("<p>1<b>2<i>3</b>4</i>5</p>")
|
314
|
+
html4_result = jruby? ? "<p>1<b>2<i>3</i></b><i>4</i>5</p>" : "<p>1<b>2<i>3</i></b>45</p>"
|
315
|
+
html5_result = jruby? ? nil : "<p>1<b>2<i>3</i></b><i>4</i>5</p>"
|
316
|
+
|
317
|
+
render_xml(<<~XML)
|
318
|
+
<root>
|
319
|
+
<contents>#{input}</contents>
|
320
|
+
</root>
|
321
|
+
XML
|
322
|
+
|
323
|
+
with_default_html_version(:html4) do
|
324
|
+
assert_select "root contents" do
|
325
|
+
assert_select_encoded do |contents|
|
326
|
+
assert_equal(html4_result, contents.to_html)
|
327
|
+
end
|
328
|
+
|
329
|
+
assert_select_encoded(html_version: :html4) do |contents|
|
330
|
+
assert_equal(html4_result, contents.to_html)
|
331
|
+
end
|
332
|
+
|
333
|
+
assert_select_encoded(html_version: :html5) do |contents|
|
334
|
+
assert_equal(html5_result, contents.to_html)
|
335
|
+
end if Rails::Dom::Testing.html5_support?
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
with_default_html_version(:html5) do
|
340
|
+
assert_select "root contents" do
|
341
|
+
assert_select_encoded do |contents|
|
342
|
+
assert_equal(html5_result, contents.to_html)
|
343
|
+
end if Rails::Dom::Testing.html5_support?
|
344
|
+
|
345
|
+
assert_select_encoded(html_version: :html4) do |contents|
|
346
|
+
assert_equal(html4_result, contents.to_html)
|
347
|
+
end
|
348
|
+
|
349
|
+
assert_select_encoded(html_version: :html5) do |contents|
|
350
|
+
assert_equal(html5_result, contents.to_html)
|
351
|
+
end if Rails::Dom::Testing.html5_support?
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
290
356
|
def test_body_not_present_in_empty_document
|
291
|
-
render_html
|
292
|
-
assert_select
|
357
|
+
render_html "<div></div>"
|
358
|
+
assert_select "body", 0
|
293
359
|
end
|
294
360
|
|
295
361
|
def test_body_class_can_be_tested
|
296
362
|
render_html '<body class="foo"></body>'
|
297
|
-
assert_select
|
363
|
+
assert_select ".foo"
|
298
364
|
end
|
299
365
|
|
300
366
|
def test_body_class_can_be_tested_with_html
|
301
367
|
render_html '<html><body class="foo"><div></div></body></html>'
|
302
|
-
assert_select
|
368
|
+
assert_select ".foo"
|
369
|
+
end
|
370
|
+
|
371
|
+
def test_assert_select_with_extra_argument
|
372
|
+
render_html "<html><head><title>Welcome</title></head><body><div></div></body></html>"
|
373
|
+
|
374
|
+
assert_raises ArgumentError do
|
375
|
+
assert_select "title", "Welcome", count: 1
|
376
|
+
end
|
377
|
+
|
378
|
+
assert_select "title", text: "Welcome", count: 1
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_assert_select_on_blank_response
|
382
|
+
render_html ""
|
383
|
+
assert_select "div", 0
|
384
|
+
assert_failure(/Expected exactly 1 element matching "div", found 0./) do
|
385
|
+
assert_select "div", 1
|
386
|
+
end
|
303
387
|
end
|
304
388
|
|
305
389
|
protected
|
@@ -315,7 +399,7 @@ EOF
|
|
315
399
|
@html_document = if content_type == :xml
|
316
400
|
Nokogiri::XML::Document.parse(content)
|
317
401
|
else
|
318
|
-
|
402
|
+
Rails::Dom::Testing.html_document.parse(content)
|
319
403
|
end
|
320
404
|
end
|
321
405
|
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails-dom-testing"
|
4
|
+
require "active_support/test_case"
|
5
|
+
require "minitest/autorun"
|
5
6
|
|
6
7
|
ActiveSupport::TestCase.test_order = :random
|
8
|
+
|
9
|
+
module DomTestingHelpers
|
10
|
+
def jruby?
|
11
|
+
!! Nokogiri.jruby?
|
12
|
+
end
|
13
|
+
|
14
|
+
def with_default_html_version(version)
|
15
|
+
old_version = Rails::Dom::Testing.default_html_version
|
16
|
+
begin
|
17
|
+
Rails::Dom::Testing.default_html_version = version
|
18
|
+
yield
|
19
|
+
ensure
|
20
|
+
Rails::Dom::Testing.default_html_version = old_version
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-dom-testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Mendonça França
|
@@ -9,50 +9,50 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: activesupport
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 5.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: minitest
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: nokogiri
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '1.
|
49
|
-
type: :
|
48
|
+
version: '1.6'
|
49
|
+
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '1.
|
55
|
+
version: '1.6'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,22 +67,8 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
-
|
71
|
-
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
84
|
-
description: " This gem can compare doms and assert certain elements exists in doms
|
85
|
-
using Nokogiri. "
|
70
|
+
description: This gem can compare doms and assert certain elements exists in doms
|
71
|
+
using Nokogiri.
|
86
72
|
email:
|
87
73
|
- rafaelmfranca@gmail.com
|
88
74
|
- kaspth@gmail.com
|
@@ -93,14 +79,16 @@ files:
|
|
93
79
|
- MIT-LICENSE
|
94
80
|
- README.md
|
95
81
|
- lib/rails-dom-testing.rb
|
82
|
+
- lib/rails/dom/testing.rb
|
96
83
|
- lib/rails/dom/testing/assertions.rb
|
97
84
|
- lib/rails/dom/testing/assertions/dom_assertions.rb
|
98
85
|
- lib/rails/dom/testing/assertions/selector_assertions.rb
|
99
|
-
- lib/rails/dom/testing/assertions/selector_assertions/count_describable.rb
|
100
86
|
- lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
|
101
87
|
- lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb
|
88
|
+
- lib/rails/dom/testing/railtie.rb
|
102
89
|
- lib/rails/dom/testing/version.rb
|
103
90
|
- test/dom_assertions_test.rb
|
91
|
+
- test/parser_selection_test.rb
|
104
92
|
- test/selector_assertions_test.rb
|
105
93
|
- test/test_helper.rb
|
106
94
|
homepage: https://github.com/rails/rails-dom-testing
|
@@ -115,19 +103,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
103
|
requirements:
|
116
104
|
- - ">="
|
117
105
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
106
|
+
version: 2.5.0
|
119
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
108
|
requirements:
|
121
109
|
- - ">="
|
122
110
|
- !ruby/object:Gem::Version
|
123
111
|
version: '0'
|
124
112
|
requirements: []
|
125
|
-
|
126
|
-
rubygems_version: 2.6.8
|
113
|
+
rubygems_version: 3.4.10
|
127
114
|
signing_key:
|
128
115
|
specification_version: 4
|
129
116
|
summary: Dom and Selector assertions for Rails applications
|
130
117
|
test_files:
|
131
118
|
- test/dom_assertions_test.rb
|
119
|
+
- test/parser_selection_test.rb
|
132
120
|
- test/selector_assertions_test.rb
|
133
121
|
- test/test_helper.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
|
3
|
-
module Rails
|
4
|
-
module Dom
|
5
|
-
module Testing
|
6
|
-
module Assertions
|
7
|
-
module SelectorAssertions
|
8
|
-
module CountDescribable
|
9
|
-
extend ActiveSupport::Concern
|
10
|
-
|
11
|
-
private
|
12
|
-
def count_description(min, max, count) #:nodoc:
|
13
|
-
if min && max && (max != min)
|
14
|
-
"between #{min} and #{max} elements"
|
15
|
-
elsif min && max && max == min && count
|
16
|
-
"exactly #{count} #{pluralize_element(min)}"
|
17
|
-
elsif min && !(min == 1 && max == 1)
|
18
|
-
"at least #{min} #{pluralize_element(min)}"
|
19
|
-
elsif max
|
20
|
-
"at most #{max} #{pluralize_element(max)}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def pluralize_element(quantity)
|
25
|
-
quantity == 1 ? 'element' : 'elements'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|