Add support for multiple matches

This commit is contained in:
Juan Pazmino
2017-05-05 22:48:14 -05:00
parent 6430f5f249
commit d1f329ee7e
3 changed files with 7 additions and 3 deletions

View File

@@ -1,3 +1,5 @@
- Fix matching mutiple calls for the same selector/function exception
## 4.3.1
- update jquery to 3.2.1

View File

@@ -91,14 +91,14 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
if block_given?
@selected ||= nil
fragments = Nokogiri::HTML::Document.new
fragments = Nokogiri::HTML::Document.new.fragment
if matched_pattern
response.body.scan(Regexp.new(matched_pattern)).each do |match|
flunk 'This function can\'t have HTML argument' if match.is_a?(String)
doc = Nokogiri::HTML::Document.parse(unescape_js(match.first))
doc.root.children.each do |child|
doc = Nokogiri::HTML::DocumentFragment.parse(unescape_js(match.first))
doc.children.each do |child|
fragments << child if child.element?
end
end

View File

@@ -10,6 +10,7 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
$("#id").html('<div><p>something</p></div>');
jQuery("#id").replaceWith("<div><p>something</p></div>");
$("<div><p>something</p></div>").appendTo("#id");
$("<div><p>something else</p></div>").appendTo("#id");
jQuery("<div><p>something</p></div>").prependTo("#id");
$('#id').remove();
jQuery("#id").hide();
@@ -41,6 +42,7 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
assert_nothing_raised do
assert_select_jquery :appendTo, '#id' do
assert_select 'p', 'something'
assert_select 'p', 'something else'
end
assert_select_jquery :prependTo, '#id' do
assert_select 'p', 'something'