Skip to content

Commit 158a6df

Browse files
committed
We don't need loofah for the assertions
We can just use nokogiri
1 parent 126a15e commit 158a6df

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

actionpack/lib/action_controller/test_case.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require 'active_support/core_ext/module/anonymous'
44
require 'active_support/core_ext/hash/keys'
55

6-
require 'loofah'
76
require 'rails-dom-testing'
87

98
module ActionController

actionpack/lib/action_dispatch/testing/assertions.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'loofah'
21
require 'rails-dom-testing'
32

43
module ActionDispatch
@@ -14,9 +13,9 @@ module Assertions
1413

1514
def html_document
1615
@html_document ||= if @response.content_type =~ /xml$/
17-
Loofah.xml_document(@response.body)
16+
Nokogiri::XML::Document.parse(@response.body)
1817
else
19-
Loofah.document(@response.body)
18+
Nokogiri::HTML::Document.parse(@response.body)
2019
end
2120
end
2221
end

actionpack/test/controller/integration_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def test_get
291291
assert_equal({}, cookies.to_hash)
292292
assert_equal "OK", body
293293
assert_equal "OK", response.body
294-
assert_kind_of Loofah::HTML::Document, html_document
294+
assert_kind_of Nokogiri::HTML::Document, html_document
295295
assert_equal 1, request_count
296296
end
297297
end
@@ -307,7 +307,7 @@ def test_post
307307
assert_equal({}, cookies.to_hash)
308308
assert_equal "Created", body
309309
assert_equal "Created", response.body
310-
assert_kind_of Loofah::HTML::Document, html_document
310+
assert_kind_of Nokogiri::HTML::Document, html_document
311311
assert_equal 1, request_count
312312
end
313313
end
@@ -367,7 +367,7 @@ def test_redirect
367367
assert_response :redirect
368368
assert_response :found
369369
assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body
370-
assert_kind_of Loofah::HTML::Document, html_document
370+
assert_kind_of Nokogiri::HTML::Document, html_document
371371
assert_equal 1, request_count
372372

373373
follow_redirect!

actionview/lib/action_view/test_case.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
require 'action_controller/test_case'
44
require 'action_view'
55

6-
require 'loofah'
76
require 'rails-dom-testing'
87

98
module ActionView
@@ -159,7 +158,7 @@ def view_rendered?(view, expected_locals)
159158

160159
# Need to experiment if this priority is the best one: rendered => output_buffer
161160
def document_root_element
162-
@html_document ||= Loofah.document(@rendered.blank? ? @output_buffer : @rendered)
161+
@html_document ||= Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered)
163162
@html_document.root
164163
end
165164

actionview/test/template/form_tag_helper_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,6 @@ def protect_against_forgery?
632632
private
633633

634634
def root_elem(rendered_content)
635-
Loofah.fragment(rendered_content).children.first # extract from nodeset
635+
Nokogiri::HTML::DocumentFragment.parse(rendered_content).children.first # extract from nodeset
636636
end
637637
end

0 commit comments

Comments
 (0)