Sha256: 21981d5d3eb60cfbef00411013848b4a7f3f47414a755141bfa528bc3c928e07

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 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/close within #{timeout_length} seconds")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
selenium-rc-2.2.4 spec/bin_selenium_rc_spec.rb
honkster-selenium-rc-2.2.2 spec/bin_selenium_rc_spec.rb
selenium-rc-2.2.1 spec/bin_selenium_rc_spec.rb
selenium-rc-2.2.0 spec/bin_selenium_rc_spec.rb