Skip to content

Commit

Permalink
Merge pull request #243 from juank-pa/support_even_more_css_selectors
Browse files Browse the repository at this point in the history
Support even more CSS selectors
  • Loading branch information
rafaelfranca committed May 12, 2017
2 parents a3ed164 + 3b2b33a commit 6eb084e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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
Expand Down
9 changes: 9 additions & 0 deletions lib/jquery/assert_select.rb
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/assert_select_jquery_test.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6eb084e

Please sign in to comment.