Sha256: 59bd1e19b0692af7dd429df0279d69869853d95ada7a58cae2fc19b4f2422e63

Contents?: true

Size: 877 Bytes

Versions: 1

Compression:

Stored size: 877 Bytes

Contents

require "phantomjs"
require "teaspoon/runner"
require 'teaspoon/utility'

module Teaspoon
  module Drivers
    class PhantomjsDriver < BaseDriver
      include Teaspoon::Utility

      def run_specs(suite, url, driver_cli_options = nil)
        runner = Teaspoon::Runner.new(suite)

        Phantomjs.instance_variable_set(:@path, executable)
        # Phantomjs.run takes the command-line args as an array, so if we need to pass in switches/flags, need to split on space
        Phantomjs.run(*([driver_cli_options && driver_cli_options.split(" "), script, url].flatten.compact)) do |line|
          runner.process(line)
        end

        runner.failure_count
      end

      protected

      def executable
        @executable ||= which('phantomjs')
      end

      def script
        File.expand_path("../phantomjs/runner.coffee", __FILE__)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teaspoon-0.7.4 lib/teaspoon/drivers/phantomjs_driver.rb