Skip to content

Commit 1efe560

Browse files
committed
Merge pull request #53 from davidcornu/raise-on-nokogiri-css-error
Stop catching Nokogiri::CSS::SyntaxError
2 parents f94ac0a + 10faac9 commit 1efe560

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ Doms are compared via `assert_dom_equal` and `assert_dom_not_equal`.
55
Elements are asserted via `assert_select`, `assert_select_encoded`, `assert_select_email` and a subset of the dom can be selected with `css_select`.
66
The gem is developed for Rails 4.2 and above, and will not work on previous versions.
77

8-
## Deprecation warnings when upgrading to Rails 4.2:
8+
## Nokogiri::CSS::SyntaxError exceptions when upgrading to Rails 4.2:
99

10-
Nokogiri is slightly more strict about the format of css selectors than the previous implementation. That's why you have warnings like:
11-
12-
```
13-
DEPRECATION WARNING: The assertion was not run because of an invalid css selector.
14-
```
10+
Nokogiri is slightly stricter about the format of CSS selectors than the previous implementation.
1511

1612
Check the 4.2 release notes [section on `assert_select`](http://edgeguides.rubyonrails.org/4_2_release_notes.html#assert-select) for help.
1713

lib/rails/dom/testing/assertions/selector_assertions.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ def css_select(*args)
6262
root = args.size == 1 ? document_root_element : args.shift
6363

6464
nodeset(root).css(args.first)
65-
rescue Nokogiri::CSS::SyntaxError => e
66-
ActiveSupport::Deprecation.warn("The assertion was not run because of an invalid css selector.\n#{e}", caller(2))
67-
return
6865
end
6966

7067
# An assertion that selects elements and makes one or more equality tests.
@@ -177,9 +174,6 @@ def assert_select(*args, &block)
177174

178175
nest_selection(matches, &block) if block_given? && !matches.empty?
179176
end
180-
rescue Nokogiri::CSS::SyntaxError => e
181-
ActiveSupport::Deprecation.warn("The assertion was not run because of an invalid css selector.\n#{e}", caller(2))
182-
return
183177
end
184178

185179
# Extracts the content of an element, treats it as encoded HTML and runs

test/selector_assertions_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,15 @@ def test_nested_css_select
220220
# testing invalid selectors
221221
def test_assert_select_with_invalid_selector
222222
render_html '<a href="http://example.com">hello</a>'
223-
assert_deprecated do
224-
assert_nil assert_select("[href=http://example.com]")
223+
assert_raises Nokogiri::CSS::SyntaxError do
224+
assert_select("[href=http://example.com]")
225225
end
226226
end
227227

228228
def test_css_select_with_invalid_selector
229229
render_html '<a href="http://example.com">hello</a>'
230-
assert_deprecated do
231-
assert_nil css_select("[href=http://example.com]")
230+
assert_raises Nokogiri::CSS::SyntaxError do
231+
css_select("[href=http://example.com]")
232232
end
233233
end
234234

0 commit comments

Comments
 (0)