Sha256: 5104e7c7fcc6a34d8ffd5c12b515754e98a92e4423b025cb0e34ba183e930377

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 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
    Lsof.kill(4444)
    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

5 entries across 5 versions & 1 rubygems

Version Path
pivotal-selenium-rc-1.10.20090610 spec/bin_selenium_rc_spec.rb
pivotal-selenium-rc-1.11.20090610 spec/bin_selenium_rc_spec.rb
pivotal-selenium-rc-1.8.20090512 spec/bin_selenium_rc_spec.rb
pivotal-selenium-rc-1.9.0 spec/bin_selenium_rc_spec.rb
pivotal-selenium-rc-1.9.20090610 spec/bin_selenium_rc_spec.rb