Module: Rails::Dom::Testing

Defined in:
lib/rails/dom/testing.rb,
lib/rails/dom/testing/railtie.rb,
lib/rails/dom/testing/version.rb,
lib/rails/dom/testing/assertions.rb,
lib/rails/dom/testing/assertions/dom_assertions.rb,
lib/rails/dom/testing/assertions/selector_assertions.rb,
lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb,
lib/rails/dom/testing/assertions/selector_assertions/substitution_context.rb

Defined Under Namespace

Modules: Assertions Classes: Railtie

Constant Summary collapse

VERSION =
"2.2.0"

Class Method Summary collapse

Class Method Details

.html5_support?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/rails/dom/testing.rb', line 15

def html5_support?
  defined?(Nokogiri::HTML5)
end

.html_document(html_version: nil) ⇒ Object



19
20
21
22
23
24
# File 'lib/rails/dom/testing.rb', line 19

def html_document(html_version: nil)
  parser_classes = { html4: Nokogiri::HTML4::Document }
  parser_classes[:html5] = Nokogiri::HTML5::Document if html5_support?

  choose_html_parser(parser_classes, html_version: html_version)
end

.html_document_fragment(html_version: nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/rails/dom/testing.rb', line 26

def html_document_fragment(html_version: nil)
  parser_classes = { html4: Nokogiri::HTML4::DocumentFragment }
  parser_classes[:html5] = Nokogiri::HTML5::DocumentFragment if html5_support?

  choose_html_parser(parser_classes, html_version: html_version)
end