diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e716a92..5a2be999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +- Add possibility to test HTML: all, attribute prefix, attribute contains, + attribute ends with, child, and class selectors - Fix matching mutiple calls for the same selector/function exception ## 4.3.1 diff --git a/lib/jquery/assert_select.rb b/lib/jquery/assert_select.rb index a7cc85b6..bae783e0 100644 --- a/lib/jquery/assert_select.rb +++ b/lib/jquery/assert_select.rb @@ -134,6 +134,15 @@ def escape_id(selector) id = selector.gsub('[', '\[') id.gsub!(']', '\]') + id.gsub!('*', '\*') + id.gsub!('(', '\(') + id.gsub!(')', '\)') + id.gsub!('.', '\.') + id.gsub!('|', '\|') + id.gsub!('^', '\^') + id.gsub!('$', '\$') + id.gsub!('+', "\\\\+") + id.gsub!(',', '\,') id end diff --git a/test/assert_select_jquery_test.rb b/test/assert_select_jquery_test.rb index dbf2c13c..ed93d519 100644 --- a/test/assert_select_jquery_test.rb +++ b/test/assert_select_jquery_test.rb @@ -16,6 +16,9 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase $('#id').remove(); jQuery("#id").hide(); $("[data-placeholder~=name]").remove(); + $("#cart tr:not(.total_line) > *").remove(); + $("[href|=\"val\"][href$=\"val\"][href^=\"val\"]").remove(); + $("tr + td, li").remove(); JS setup do @@ -32,6 +35,9 @@ def test_target_as_receiver assert_select 'p', 'something' end assert_select_jquery :remove, "[data-placeholder~=name]" + assert_select_jquery :remove, "#cart tr:not(.total_line) > *" + assert_select_jquery :remove, "[href|=\"val\"][href$=\"val\"][href^=\"val\"]" + assert_select_jquery :remove, "tr + td, li" end assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do