Sha256: f3a8bf955acae9ddc310e3fd6be36a64a36b482bebca3f88d4177dfd072219b5

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 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

    timeout {SeleniumRC::Server.service_is_running?}
    thread.kill
    timeout {!SeleniumRC::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

2 entries across 2 versions & 1 rubygems

Version Path
pivotal-selenium-rc-1.6.20090512 spec/install_and_run_spec.rb
pivotal-selenium-rc-1.7.20090512 spec/install_and_run_spec.rb