Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias assert_select methods to assert_dom versions #93

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
PATH
remote: .
specs:
rails-dom-testing (2.0.2)
activesupport (>= 4.2.0)
rails-dom-testing (2.0.3)
activesupport (>= 5.0.0)
nokogiri (>= 1.6)

GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.3.1)
activesupport (6.1.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
concurrent-ruby (1.1.6)
i18n (1.8.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
concurrent-ruby (1.1.8)
i18n (1.8.9)
concurrent-ruby (~> 1.0)
mini_portile2 (2.4.0)
minitest (5.10.1)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
nokogiri (1.11.1)
racc (~> 1.4)
racc (1.5.2)
rake (13.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
zeitwerk (2.3.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)

PLATFORMS
ruby
Expand Down
3 changes: 3 additions & 0 deletions lib/rails/dom/testing/assertions/selector_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def assert_select(*args, &block)
nest_selection(matches, &block) if block_given? && !matches.empty?
end
end
alias_method :assert_dom, :assert_select
deprecate assert_select: "assert_select will be renamed to assert_dom in an upcoming release"

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

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

private
Expand Down
4 changes: 4 additions & 0 deletions test/selector_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def assert_failure(message, &block)
def test_assert_select
render_html %Q{<div id="1"></div><div id="2"></div>}
assert_select "div", 2
assert_dom "div", 2
assert_failure(/Expected at least 1 element matching \"p\", found 0/) { assert_select "p" }
end

Expand Down Expand Up @@ -277,6 +278,9 @@ def test_feed_item_encoded
assert_select_encoded do
assert_select "p", :count=>2, :text=>/Test/
end
assert_dom_encoded do
assert_select "p", :count=>2, :text=>/Test/
end

# Test individually.
assert_select "description" do |elements|
Expand Down