Skip to content

Commit 267487e

Browse files
authored
Merge pull request #93 from seanpdoyle/alias-assert-dom-methods
Alias assert_select methods to assert_dom versions
2 parents 7566b4f + 949f7ce commit 267487e

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

Gemfile.lock

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
PATH
22
remote: .
33
specs:
4-
rails-dom-testing (2.0.2)
5-
activesupport (>= 4.2.0)
4+
rails-dom-testing (2.0.3)
5+
activesupport (>= 5.0.0)
66
nokogiri (>= 1.6)
77

88
GEM
99
remote: https://rubygems.org/
1010
specs:
11-
activesupport (6.0.3.1)
11+
activesupport (6.1.2.1)
1212
concurrent-ruby (~> 1.0, >= 1.0.2)
13-
i18n (>= 0.7, < 2)
14-
minitest (~> 5.1)
15-
tzinfo (~> 1.1)
16-
zeitwerk (~> 2.2, >= 2.2.2)
17-
concurrent-ruby (1.1.6)
18-
i18n (1.8.2)
13+
i18n (>= 1.6, < 2)
14+
minitest (>= 5.1)
15+
tzinfo (~> 2.0)
16+
zeitwerk (~> 2.3)
17+
concurrent-ruby (1.1.8)
18+
i18n (1.8.9)
1919
concurrent-ruby (~> 1.0)
20-
mini_portile2 (2.4.0)
2120
minitest (5.10.1)
22-
nokogiri (1.10.9)
23-
mini_portile2 (~> 2.4.0)
21+
nokogiri (1.11.1)
22+
racc (~> 1.4)
23+
racc (1.5.2)
2424
rake (13.0.1)
25-
thread_safe (0.3.6)
26-
tzinfo (1.2.7)
27-
thread_safe (~> 0.1)
28-
zeitwerk (2.3.0)
25+
tzinfo (2.0.4)
26+
concurrent-ruby (~> 1.0)
27+
zeitwerk (2.4.2)
2928

3029
PLATFORMS
3130
ruby

lib/rails/dom/testing/assertions/selector_assertions.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def assert_select(*args, &block)
178178
nest_selection(matches, &block) if block_given? && !matches.empty?
179179
end
180180
end
181+
alias_method :assert_dom, :assert_select
181182
deprecate assert_select: "assert_select will be renamed to assert_dom in an upcoming release"
182183

183184
# Extracts the content of an element, treats it as encoded HTML and runs
@@ -232,6 +233,7 @@ def assert_select_encoded(element = nil, &block)
232233
end
233234
end
234235
end
236+
alias_method :assert_dom_encoded, :assert_select_encoded
235237
deprecate assert_select_encoded: "assert_select_encoded will be renamed to assert_dom_encoded in an upcoming release"
236238

237239
# Extracts the body of an email and runs nested assertions on it.
@@ -262,6 +264,7 @@ def assert_select_email(&block)
262264
end
263265
end
264266
end
267+
alias_method :assert_dom_email, :assert_select_email
265268
deprecate assert_select_email: "assert_select_email will be renamed to assert_dom_email in an upcoming release"
266269

267270
private

test/selector_assertions_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def assert_failure(message, &block)
2121
def test_assert_select
2222
render_html %Q{<div id="1"></div><div id="2"></div>}
2323
assert_select "div", 2
24+
assert_dom "div", 2
2425
assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" }
2526
end
2627

@@ -277,6 +278,9 @@ def test_feed_item_encoded
277278
assert_select_encoded do
278279
assert_select "p", :count=>2, :text=>/Test/
279280
end
281+
assert_dom_encoded do
282+
assert_select "p", :count=>2, :text=>/Test/
283+
end
280284

281285
# Test individually.
282286
assert_select "description" do |elements|

0 commit comments

Comments
 (0)