Sha256: 423228e62f168b31fb8fa978ad8025d899c84280bd9187b1d4a93862541f8004

Contents?: true

Size: 1.45 KB

Versions: 23

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module ViewComponentTestHelpers
  # Work around for https://github.com/teamcapybara/capybara/issues/2466
  def render_inline_to_capybara_node(component)
    Capybara::Node::Simple.new(render_inline(component).to_s)
  end

  # Work-around for https://github.com/ViewComponent/view_component/pull/1661
  # which made the component test's controller method (more) private. This makes
  # it available so we can set up controller-level state for our tests.
  def controller
    # ViewComponent 2.x
    return super if defined?(super)

    # ViewComponent 3.x
    return vc_test_controller if defined?(vc_test_controller)

    ApplicationController.new.extend(Rails.application.routes.url_helpers)
  end

  # Nokogiri 1.15.0 upgrades the vendored libxml2 from v2.10.4 to v2.11.3
  # libxml2 v2.11.0 introduces a change to parsing HTML href attributes
  # in nokogiri < 1.15, brackets in href attributes are escaped:
  # - <a class="facet-select" rel="nofollow" href="/catalog?f%5Bz%5D%5B%5D=x:1">x:1</a>
  # in nokogiri >= 1.15, brackets in href attributes are not escaped:
  # - <a class="facet-select" rel="nofollow" href="/catalog?f[z][]=x:1">x:1</a>
  # until we can spec a minimum nokogiri version of 1.15.0, we need to see how
  # the installed version parsed the html
  def nokogiri_mediated_href(href)
    start = "<a href=\"".length
    stop = -"\"></a>".length
    Nokogiri::HTML.fragment("<a href=\"#{href}\"></a>").to_s[start...stop]
  end
end

Version data entries

23 entries across 22 versions & 2 rubygems

Version Path
blacklight-8.8.0 spec/support/view_component_test_helpers.rb
blacklight-8.7.0 spec/support/view_component_test_helpers.rb
blacklight-8.6.1 spec/support/view_component_test_helpers.rb
blacklight-7.40.0 spec/support/view_component_test_helpers.rb
blacklight-8.6.0 spec/support/view_component_test_helpers.rb
blacklight-8.5.1 spec/support/view_component_test_helpers.rb
blacklight-8.5.0 spec/support/view_component_test_helpers.rb
blacklight-7.39.0 spec/support/view_component_test_helpers.rb
blacklight-8.4.0 spec/support/view_component_test_helpers.rb
blacklight-7.38.0 spec/support/view_component_test_helpers.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/support/view_component_test_helpers.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/spec/support/view_component_test_helpers.rb
blacklight-8.3.0 spec/support/view_component_test_helpers.rb
blacklight-8.2.2 spec/support/view_component_test_helpers.rb
blacklight-8.2.1 spec/support/view_component_test_helpers.rb
blacklight-8.2.0 spec/support/view_component_test_helpers.rb
blacklight-7.37.0 spec/support/view_component_test_helpers.rb
blacklight-7.36.2 spec/support/view_component_test_helpers.rb
blacklight-7.36.1 spec/support/view_component_test_helpers.rb
blacklight-7.36.0 spec/support/view_component_test_helpers.rb