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
Change assert_dom
to scope with NodeSet
#94
Conversation
I've responded to the latest feedback, thanks for the review. I think you've picked up on the subtext, but it might be worth stating outright: I've named the method That isn't a technical requirement, though. As an alternative, this change could achieve the same outcome by modifying the More methods means a larger interface to maintain into the future, and tweaking existing behavior risks breaking backwards compatibility. @rafaelfranca @kaspth Do either of you have a preference on whether or not we should add a new method to the interface? |
07290df
to
6d06f8c
Compare
@kaspth I've pushed up changes to revert the introduction of It's currently passing. There is one additional test case I considered adding: diff --git a/test/selector_assertions_test.rb b/test/selector_assertions_test.rb
index 454a5ab..4f08900 100644
--- a/test/selector_assertions_test.rb
+++ b/test/selector_assertions_test.rb
@@ -227,6 +227,20 @@ class AssertSelectTest < ActiveSupport::TestCase
assert_dom "aside", text: "other", count: 1
end
+ def test_assert_dom_with_nodeset_and_options
+ render_html %Q{<div><span>foo</span></div><div><span>bar</span></div>}
+
+ assert_dom css_select("div"), count: 2
+ assert_dom css_select("div"), minimum: 1, maximum: 2
+
+ assert_raises Minitest::Assertion do
+ assert_dom css_select("div"), count: 1
+ end
+ assert_raises Minitest::Assertion do
+ assert_dom css_select("div"), minimum: 3
+ end
+ end
+
|
assert_dom
to scope with NodeSet
Change `assert_dom` to accept a single `Nokogiri::XML::Node` or a `Nokogiri::XML::NodeSet` as an argument without supplementary set of CSS or XPath selectors. ```ruby assert_dom document_root_element.at_css("main") do assert_dom "h1", "Hello, World" end assert_dom css_select("section") do assert_dom "h1" end ``` This change is in support of making [rails/rails#41291][] possible: ```diff require "test_helper" + require "capybara/minitest" class ActionDispatch::IntegrationTest + include Capybara::Minitest::Assertions + + def page + Capybara.string(current_root_element) + end + + def within(*arguments, **options, &block) + assert_dom page.find(*arguments, **options), &block + end end ``` [rails/rails#41291]: rails/rails#41291
I've opened rails/rails#43361 to add a public method to hook Capybara integration with ActionDispatch::IntegationTest onto. I'd rather explore that option than continue to change |
Change
assert_dom
to accept a singleNokogiri::XML::Node
or aNokogiri::XML::NodeSet
as an argument without supplementary set of CSSor XPath selectors.
This change is in support of making rails/rails#41291 possible: