Update assert_select for Nokogiri compatibility

assert_select has been moved into the rails-dom-testing gem and is now
based on Nokogiri.

* Remove assert_tag and assert_xml_select
* Quote CSS attribute selector values
* Use decoded versions of HTML in assert_select. Nokogiri decodes
  elements prior to matching.
* Add a test helper for entities such as ` ` for which it's
  difficult or confusing to include the decoded version directly in the
  assertion.
* Assert directly on Atom feeds' XML namespace because it isn't
  selectable as an attribute
This commit is contained in:
Dan Rice 2015-08-09 17:43:40 -04:00
parent d7d86446c0
commit 689db4c9c3
9 changed files with 66 additions and 64 deletions

View file

@ -56,15 +56,6 @@ class ActiveSupport::TestCase
def assert_equal_dmy(date1, date2)
assert_equal date1.strftime("%d-%m-%y"), date2.strftime("%d-%m-%y")
end
def xml_document
@xml_document ||= HTML::Document.new(@response.body, false, true)
end
def assert_xml_select(*args, &block)
@html_document = xml_document
assert_select(*args, &block)
end
end
class ActionController::TestCase
@ -90,11 +81,6 @@ class ActionController::TestCase
xhr :post, :create, get_model_class.downcase => {:name => name}
end
def assert_xml_select(*args, &block)
@html_document = xml_document
assert_select(*args, &block)
end
private
def get_model_class
@ -145,7 +131,7 @@ class ActionDispatch::IntegrationTest
def assert_responses_with_error(error_msg)
assert_response 409
assert_xml_select 'errors' do
assert_select 'errors' do
assert_select 'error', 1, error_msg
end
end