提交 f939904f 编写于 作者: K Kasper Timm Hansen

Parse HTML as document fragment.

This is to match the changes in Rails Dom Testing rails/rails-dom-testing#20.
上级 035cc69c
......@@ -2,6 +2,8 @@ source 'https://rubygems.org'
gemspec
gem 'rails-dom-testing', github: 'rails/rails-dom-testing'
# We need a newish Rake since Active Job sets its test tasks' descriptions.
gem 'rake', '>= 10.3'
......
......@@ -689,7 +689,7 @@ def build_response(klass)
private
def document_root_element
html_document.root
html_document
end
def check_required_ivars
......
......@@ -15,7 +15,7 @@ def html_document
@html_document ||= if @response.content_type =~ /xml$/
Nokogiri::XML::Document.parse(@response.body)
else
Nokogiri::HTML::Document.parse(@response.body)
Nokogiri::HTML::DocumentFragment.parse(@response.body)
end
end
end
......
......@@ -497,7 +497,7 @@ def url_options
end
def document_root_element
html_document.root
html_document
end
end
end
......@@ -292,7 +292,7 @@ def test_get
assert_equal({}, cookies.to_hash)
assert_equal "OK", body
assert_equal "OK", response.body
assert_kind_of Nokogiri::HTML::Document, html_document
assert_kind_of Nokogiri::HTML::DocumentFragment, html_document
assert_equal 1, request_count
end
end
......@@ -308,7 +308,7 @@ def test_post
assert_equal({}, cookies.to_hash)
assert_equal "Created", body
assert_equal "Created", response.body
assert_kind_of Nokogiri::HTML::Document, html_document
assert_kind_of Nokogiri::HTML::DocumentFragment, html_document
assert_equal 1, request_count
end
end
......@@ -368,7 +368,7 @@ def test_redirect
assert_response :redirect
assert_response :found
assert_equal "<html><body>You are being <a href=\"http://www.example.com/get\">redirected</a>.</body></html>", response.body
assert_kind_of Nokogiri::HTML::Document, html_document
assert_kind_of Nokogiri::HTML::DocumentFragment, html_document
assert_equal 1, request_count
follow_redirect!
......
......@@ -158,7 +158,7 @@ def view_rendered?(view, expected_locals)
# Need to experiment if this priority is the best one: rendered => output_buffer
def document_root_element
Nokogiri::HTML::Document.parse(@rendered.blank? ? @output_buffer : @rendered).root
Nokogiri::HTML::DocumentFragment.parse(@rendered.blank? ? @output_buffer : @rendered)
end
def say_no_to_protect_against_forgery!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册