Sha256: 70a3a1b7ff8c722f059f8ea24e517d8ad61397ffdf6db7e9be01b0ff19b4fd27

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")

describe "bin/selenium-rc" do
  attr_reader :root_dir
  before do
    dir = File.dirname(__FILE__)
    @root_dir = File.expand_path("#{dir}/..")
    unless File.exists?("#{root_dir}/vendor/selenium-server.jar")
      raise "vendor/selenium-server.jar does not exist. Try running `rake download_jar_file` to install the jar file."
    end
  end

  it "starts the SeleniumRC server from the downloaded jar file and terminates it when finished" do
    thread = nil
    Dir.chdir(root_dir) do
      thread = Thread.start do
        system("bin/selenium-rc") || raise("bin/selenium-server failed")
      end
    end

    server = SeleniumRC::Server.new("0.0.0.0")

    timeout {server.service_is_running?}
    thread.kill
    Lsof.kill(4444)
    timeout {!server.service_is_running?}
  end

  def timeout
    start_time = Time.now
    timeout_length = 15
    until yield
      if Time.now > (start_time + timeout_length)
        raise SocketError.new("Socket did not open within #{timeout_length} seconds")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selenium-rc-2.1.0 spec/bin_selenium_rc_spec.rb