Merge pull request #243 from juank-pa/support_even_more_css_selectors

Support even more CSS selectors
This commit is contained in:
Rafael França
2017-05-11 22:15:46 -07:00
committed by GitHub
3 changed files with 17 additions and 0 deletions

View File

@@ -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

View File

@@ -134,6 +134,15 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
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

View File

@@ -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 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
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