Skip to content

Commit 6eb084e

Browse files
authored
Merge pull request #243 from juank-pa/support_even_more_css_selectors
Support even more CSS selectors
2 parents a3ed164 + 3b2b33a commit 6eb084e

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- Add possibility to test HTML: all, attribute prefix, attribute contains,
2+
attribute ends with, child, and class selectors
13
- Fix matching mutiple calls for the same selector/function exception
24

35
## 4.3.1

lib/jquery/assert_select.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ def escape_id(selector)
134134

135135
id = selector.gsub('[', '\[')
136136
id.gsub!(']', '\]')
137+
id.gsub!('*', '\*')
138+
id.gsub!('(', '\(')
139+
id.gsub!(')', '\)')
140+
id.gsub!('.', '\.')
141+
id.gsub!('|', '\|')
142+
id.gsub!('^', '\^')
143+
id.gsub!('$', '\$')
144+
id.gsub!('+', "\\\\+")
145+
id.gsub!(',', '\,')
137146

138147
id
139148
end

test/assert_select_jquery_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
1616
$('#id').remove();
1717
jQuery("#id").hide();
1818
$("[data-placeholder~=name]").remove();
19+
$("#cart tr:not(.total_line) > *").remove();
20+
$("[href|=\"val\"][href$=\"val\"][href^=\"val\"]").remove();
21+
$("tr + td, li").remove();
1922
JS
2023

2124
setup do
@@ -32,6 +35,9 @@ def test_target_as_receiver
3235
assert_select 'p', 'something'
3336
end
3437
assert_select_jquery :remove, "[data-placeholder~=name]"
38+
assert_select_jquery :remove, "#cart tr:not(.total_line) > *"
39+
assert_select_jquery :remove, "[href|=\"val\"][href$=\"val\"][href^=\"val\"]"
40+
assert_select_jquery :remove, "tr + td, li"
3541
end
3642

3743
assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do

0 commit comments

Comments
 (0)