Sha256: 50414f6d96e86b697073339c74c32f7c409e585b464e6b9f9d74b2c28c66eb68

Contents?: true

Size: 521 Bytes

Versions: 2

Compression:

Stored size: 521 Bytes

Contents

require 'sfl'

module Capybara::Poltergeist
  class Client
    PHANTOM_SCRIPT = File.expand_path('../client/compiled/main.js', __FILE__)

    attr_reader :thread, :pid, :err, :port, :path

    def initialize(port, path = nil)
      @port = port
      @path = path || 'phantomjs'

      start
      at_exit { stop }
    end

    def start
      @pid = Kernel.spawn("#{path} #{PHANTOM_SCRIPT} #{port}")
    end

    def stop
      Process.kill('TERM', pid)
    end

    def restart
      stop
      start
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
poltergeist-0.3.0 lib/capybara/poltergeist/client.rb
poltergeist-0.2.0 lib/capybara/poltergeist/client.rb