Sha256: ee42ca3d6e2405aedae0289ccba8b4a96c09005c592dfe1fcad290c92e17e7ac

Contents?: true

Size: 734 Bytes

Versions: 5

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

module AmberComponent
  # Provides assertions for the rendered
  # HTML of components.
  module TestHelper
    begin
      require 'capybara/minitest'
      include ::Capybara::Minitest::Assertions

      def page
        @page ||= ::Capybara::Node::Simple.new(@rendered_content)
      end
    rescue ::LoadError
      nil
    end

    # @return [Nokogiri::HTML]
    def document
      ::Nokogiri::HTML.fragment(@rendered_content)
    end
    alias doc document
    alias html document

    # @param content [String]
    # @return [Nokogiri::HTML]
    def render(content = nil)
      @page = nil
      @rendered_content = content || yield
      document
    end
    alias render_inline render
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
amber_component-1.2.0 lib/amber_component/test_helper.rb
amber_component-1.1.1 lib/amber_component/test_helper.rb
amber_component-1.1.0 lib/amber_component/test_helper.rb
amber_component-1.0.0 lib/amber_component/test_helper.rb
amber_component-0.0.5 lib/amber_component/test_helper.rb