Sha256: 44db3e621e195421e8104a23356a0e377d7ddbde5bff8bd1c1e11ab6510cadef

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# :nocov:
begin
  require "capybara-webkit"
rescue LoadError
  Teaspoon.abort("Could not find Capybara Webkit. Install the capybara-webkit gem.")
end
# :nocov:

require "teaspoon/driver/base"

module Teaspoon
  module Driver
    class CapybaraWebkit < Base
      class TeaspoonNotFinishedError < StandardError; end
      def initialize(_options = nil)
      end

      def run_specs(runner, url)
        session.visit(url)

        timeout = Teaspoon.configuration.driver_timeout.to_i
        session.document.synchronize(timeout, errors: [TeaspoonNotFinishedError]) do
          done = session.evaluate_script("window.Teaspoon && window.Teaspoon.finished")
          (session.evaluate_script("window.Teaspoon && window.Teaspoon.getMessages()") || []).each do |line|
            runner.process("#{line}\n")
          end
          unless done
            raise TeaspoonNotFinishedError
          end
        end
      end

      private

      def session
        @session ||= Capybara::Session.new(:webkit)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
teaspoon-1.1.5 lib/teaspoon/driver/capybara_webkit.rb
teaspoon-1.1.4 lib/teaspoon/driver/capybara_webkit.rb
teaspoon-1.1.3 lib/teaspoon/driver/capybara_webkit.rb
teaspoon-1.1.2 lib/teaspoon/driver/capybara_webkit.rb
teaspoon-1.1.1 lib/teaspoon/driver/capybara_webkit.rb
teaspoon-1.1.0 lib/teaspoon/driver/capybara_webkit.rb