Sha256: 39aaf1e2639e5d9cd3c91e3f1fd74688f33a7b6fd4a523d5368e2973044191ee

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require "rubygems"

require File.join(File.dirname(__FILE__), "..", "lib", "selenium", "rc_server")

require "contest"
require "override"

# Make sure we're not trying to start or stop.
Selenium::RemoteControl::RemoteControl = Class.new(Selenium::RemoteControl::RemoteControl) do
  def start(*args)
    raise "Can't actually call #start in tests."
  end
  
  def stop(*args)
    raise "Can't actually call #stop in tests."
  end
end

class RCServerTest < Test::Unit::TestCase
  include Override

  setup do
    @server = Selenium::RCServer.new(nil, "1234", :timeout => 10)
    @rc = @server.remote_control
  end

  should "have a remote control instance" do
    assert_nil @rc.host
    assert_equal "1234", @rc.port
    assert_equal 10, @rc.timeout_in_seconds
    assert_equal File.expand_path(File.join(File.dirname(__FILE__), "..", "vendor", "selenium-server.jar")), @rc.jar_file
  end

  should "start" do
    expect(@rc, :start, :with => [{:background => true}])
    @server.start
  end

  should "stop" do
    expect(@rc, :stop, :with => [])
    @server.stop
  end

  should "boot" do
    expect(@rc, :start, :with => [{:background => true}])
    expect(TCPSocket, :wait_for_service_with_timeout, :with => [{:host => "0.0.0.0", :port => "1234", :timeout => 15}])
    expect(@rc, :stop, :with => [])

    @server.boot
  end

  should "not boot if it's a grid" do
    server = Selenium::RCServer.new("127.0.0.1", "1234", :timeout => 10)

    assert_nil server.boot
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selenium-rc-0.0.1 test/rc_server_test.rb