Sha256: cc7cbe4b5882bef83202ac446cf9553c66cc82d4d0d4a6e8c5912aab94959952

Contents?: true

Size: 802 Bytes

Versions: 5

Compression:

Stored size: 802 Bytes

Contents

require "capybara/rails"

module ActionDispatch
  class IntegrationTest
    include Capybara::DSL

    setup do
      Capybara.reset_sessions!
      Capybara.use_default_driver
    end

    def self.use_javascript!(raise_on_javascript_errors: true)
      setup do
        Capybara.current_driver = Capybara.javascript_driver
      end

      teardown do
        next if failures.any?
        next unless raise_on_javascript_errors

        errors = page.driver.browser.manage.logs.get(:browser).select {|log| log.level == "SEVERE" }
        next unless errors.any?

        messages = errors
                    .map(&:message)
                    .map {|message| message[/(\d+:\d+ .*?)$/, 1] }
                    .join("\n")
        raise "JavaScript Errors\n#{messages}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
minitest-utils-0.4.4 lib/minitest/utils/rails/capybara.rb
minitest-utils-0.4.3 lib/minitest/utils/rails/capybara.rb
minitest-utils-0.4.2 lib/minitest/utils/rails/capybara.rb
minitest-utils-0.4.1 lib/minitest/utils/rails/capybara.rb
minitest-utils-0.4.0 lib/minitest/utils/rails/capybara.rb