Sha256: b1088b9ffa916846df5a9a2c3f0cf4f89869f1b4a16841d8bd70575e091f4e16

Contents?: true

Size: 905 Bytes

Versions: 4

Compression:

Stored size: 905 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) if line && line.strip != ""
        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

4 entries across 4 versions & 1 rubygems

Version Path
teaspoon-0.7.8 lib/teaspoon/drivers/phantomjs_driver.rb
teaspoon-0.7.7 lib/teaspoon/drivers/phantomjs_driver.rb
teaspoon-0.7.6 lib/teaspoon/drivers/phantomjs_driver.rb
teaspoon-0.7.5 lib/teaspoon/drivers/phantomjs_driver.rb