mirror of
https://github.com/rails/jquery-rails.git
synced 2026-01-10 07:07:54 -05:00
Add support for multiple matches
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
- Fix matching mutiple calls for the same selector/function exception
|
||||
|
||||
## 4.3.1
|
||||
|
||||
- update jquery to 3.2.1
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user