honkster-selenium-rc 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES ADDED
@@ -0,0 +1,9 @@
1
+ 1.8.20090512
2
+ Fixed bug where bin/selenium-rc did not stay open
3
+
4
+ 1.7.20090512
5
+ Properly handling Errno::EADDRNOTAVAIL when starting on windows.
6
+
7
+ 1.6.20090512
8
+ Properly terminate server when the process exits.
9
+ Fixed server blocking the process issue.
data/README.markdown ADDED
@@ -0,0 +1,5 @@
1
+ # selenium-rc #
2
+
3
+ Ruby wrapper for the Selenium RC jar. Bundles the jar and provides a binary and Rake tasks to manage them.
4
+
5
+ Selenium RC Home Page: [http://seleniumhq.org/projects/remote-control](http://seleniumhq.org/projects/remote-control)
data/RELEASING ADDED
@@ -0,0 +1,14 @@
1
+ In order to build the gem you need to have Joe installed.
2
+ The full README is located at http://github.com/djanowski/joe,
3
+ but if you're in a rush this is the list of things to do:
4
+
5
+ $ sudo gem install rubyforge
6
+ $ rubyforge setup
7
+ $ rubyforge config
8
+
9
+ $ sudo gem install thor
10
+ $ thor install http://dimaion.com/joe/joe.thor
11
+
12
+ And finally,
13
+
14
+ $ thor joe:release
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "spec"
2
+ require "spec/rake/spectask"
3
+
4
+ task :default => :spec
5
+
6
+ desc "Run all examples"
7
+ Spec::Rake::SpecTask.new("spec") do |t|
8
+ t.spec_files = FileList["spec/**/*_spec.rb"]
9
+ end
data/Thorfile ADDED
@@ -0,0 +1,27 @@
1
+ require "zip/zip"
2
+
3
+ class Joe < Thor
4
+ alias_method :joe_build, :build
5
+ def build
6
+ fetch_jar
7
+ joe_build
8
+ end
9
+
10
+ def fetch_jar
11
+ url = "http://selenium.googlecode.com/files/selenium-server-standalone-2.0a2.jar"
12
+ file = File.join("tmp", File.basename(url))
13
+
14
+ FileUtils.mkdir_p("tmp")
15
+
16
+ system "wget #{url} -O #{file}" unless File.exist?(file)
17
+
18
+ FileUtils.mv("#{file}", "vendor/selenium-server.jar")
19
+
20
+ # Zip::ZipFile.open(file) do |zipfile|
21
+ # jar_file_entry = zipfile.entries.find {|file| file.name =~ /selenium-server-standalone-2\.0a1\.jar$/}
22
+ # destination = "vendor/selenium-server.jar"
23
+ # FileUtils.rm_rf(destination)
24
+ # zipfile.extract(jar_file_entry, destination)
25
+ # end
26
+ end
27
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 2
3
+ :minor: 2
4
+ :patch: 2
data/bin/selenium-rc ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "selenium_rc"))
4
+
5
+ SeleniumRC::Server.boot(
6
+ ENV["SELENIUM_SERVER_HOST"] || "0.0.0.0",
7
+ ENV["SELENIUM_SERVER_PORT"],
8
+ :args => ARGV
9
+ )
10
+
11
+ sleep
@@ -0,0 +1,4 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "socket"
3
+ require "#{dir}/selenium_rc/server"
4
+ require "net/http"
@@ -0,0 +1,101 @@
1
+ module SeleniumRC
2
+
3
+ class Server
4
+ attr_accessor :host
5
+ attr_accessor :port
6
+ attr_accessor :args
7
+ attr_accessor :timeout
8
+
9
+ def self.boot(*args)
10
+ new(*args).boot
11
+ end
12
+
13
+ def initialize(host, port = nil, options = {})
14
+ @host = host
15
+ @port = port || 4444
16
+ @args = options[:args] || []
17
+ @timeout = options[:timeout]
18
+ end
19
+
20
+ def boot
21
+ start
22
+ wait
23
+ stop_at_exit
24
+ self
25
+ end
26
+
27
+ def log(string)
28
+ puts string
29
+ end
30
+
31
+ def start
32
+ command = "java -jar \"#{jar_path}\""
33
+ command << " -port #{port}"
34
+ command << " #{args.join(' ')}" unless args.empty?
35
+ log "Running: #{command}"
36
+ begin
37
+ fork do
38
+ system(command)
39
+ end
40
+ rescue NotImplementedError
41
+ Thread.start do
42
+ system(command)
43
+ end
44
+ end
45
+ end
46
+
47
+ def stop_at_exit
48
+ at_exit do
49
+ stop
50
+ end
51
+ end
52
+
53
+ def jar_path
54
+ File.expand_path("#{File.dirname(__FILE__)}/../../vendor/selenium-server.jar")
55
+ end
56
+
57
+ def wait
58
+ $stderr.print "==> Waiting for Selenium RC server on port #{port}... "
59
+ wait_for_service_with_timeout
60
+ $stderr.print "Ready!\n"
61
+ rescue SocketError
62
+ fail
63
+ end
64
+
65
+ def fail
66
+ $stderr.puts
67
+ $stderr.puts
68
+ $stderr.puts "==> Failed to boot the Selenium RC server... exiting!"
69
+ exit
70
+ end
71
+
72
+ def stop
73
+ Net::HTTP.get(host, '/selenium-server/driver/?cmd=shutDownSeleniumServer', port)
74
+ end
75
+
76
+ def service_is_running?
77
+ begin
78
+ socket = TCPSocket.new(host, port)
79
+ socket.close unless socket.nil?
80
+ true
81
+ rescue Errno::ECONNREFUSED,
82
+ Errno::EBADF, # Windows
83
+ Errno::EADDRNOTAVAIL # Windows
84
+ false
85
+ end
86
+ end
87
+
88
+ protected
89
+ def wait_for_service_with_timeout
90
+ start_time = Time.now
91
+ timeout = 60
92
+
93
+ until service_is_running?
94
+ if timeout && (Time.now > (start_time + timeout))
95
+ raise SocketError.new("Socket did not open within #{timeout} seconds")
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,38 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
+
3
+ describe "bin/selenium-rc" do
4
+ attr_reader :root_dir
5
+ before do
6
+ dir = File.dirname(__FILE__)
7
+ @root_dir = File.expand_path("#{dir}/..")
8
+ unless File.exists?("#{root_dir}/vendor/selenium-server.jar")
9
+ raise "vendor/selenium-server.jar does not exist. Try running `rake download_jar_file` to install the jar file."
10
+ end
11
+ end
12
+
13
+ it "starts the SeleniumRC server from the downloaded jar file and terminates it when finished" do
14
+ thread = nil
15
+ Dir.chdir(root_dir) do
16
+ thread = Thread.start do
17
+ system("bin/selenium-rc") || raise("bin/selenium-server failed")
18
+ end
19
+ end
20
+
21
+ server = SeleniumRC::Server.new("0.0.0.0")
22
+
23
+ timeout {server.service_is_running?}
24
+ thread.kill
25
+ Lsof.kill(4444)
26
+ timeout {!server.service_is_running?}
27
+ end
28
+
29
+ def timeout
30
+ start_time = Time.now
31
+ timeout_length = 15
32
+ until yield
33
+ if Time.now > (start_time + timeout_length)
34
+ raise SocketError.new("Socket did not open/close within #{timeout_length} seconds")
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")
2
+
3
+ module SeleniumRC
4
+ describe Server do
5
+
6
+ def new_server(*args)
7
+ server = Server.new(*args)
8
+ stub(server).log
9
+ stub(server).fork.yields
10
+ server
11
+ end
12
+
13
+ describe "#start" do
14
+ it "launches java with the jar file and port" do
15
+ @server = new_server("0.0.0.0", 5555)
16
+
17
+ expected_command = %Q{java -jar "/path/to/the.jar" -port 5555}
18
+ mock(@server).system(expected_command)
19
+ mock(@server).jar_path {"/path/to/the.jar"}
20
+ @server.start
21
+ end
22
+
23
+ context "when passed additional arguments" do
24
+ it "adds the additional arguments to the selenium start command" do
25
+ @server = new_server("0.0.0.0", 4444, :args => ["-browserSideLog", "-suppressStupidness"])
26
+ expected_command = %Q{java -jar "/path/to/the.jar" -port 4444 -browserSideLog -suppressStupidness}
27
+ mock(@server).system(expected_command)
28
+ mock(@server).jar_path {"/path/to/the.jar"}
29
+ @server.start
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ require "rubygems"
2
+ require "spec"
3
+ require "spec/autorun"
4
+ require "fileutils"
5
+ require "timeout"
6
+ require "tcp_socket_extension"
7
+ require "rr"
8
+ require "lsof"
9
+
10
+ dir = File.dirname(__FILE__)
11
+ $:.unshift(File.expand_path("#{dir}/../lib"))
12
+ require "selenium_rc"
13
+
14
+ Spec::Runner.configure do |config|
15
+ config.mock_with :rr
16
+ end
@@ -0,0 +1,3 @@
1
+ Dir["#{File.dirname(__FILE__)}/**/*_spec.rb"].each do |file|
2
+ require file
3
+ end
data/vendor/empty.txt ADDED
File without changes
Binary file
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: honkster-selenium-rc
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Pivotal Labs
8
+ - Nate Clark
9
+ - Brian Takita
10
+ - Chad Woolley
11
+ - Matthew Kocher
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-03-04 00:00:00 -08:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: selenium-client
21
+ type: :runtime
22
+ version_requirement:
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.2.18
28
+ version:
29
+ description: The Selenium RC Server packaged as a gem
30
+ email: pivotallabsopensource@googlegroups.com
31
+ executables:
32
+ - selenium-rc
33
+ extensions: []
34
+
35
+ extra_rdoc_files:
36
+ - README.markdown
37
+ files:
38
+ - Thorfile
39
+ - Rakefile
40
+ - README.markdown
41
+ - RELEASING
42
+ - CHANGES
43
+ - VERSION.yml
44
+ - bin/selenium-rc
45
+ - lib/selenium_rc/server.rb
46
+ - lib/selenium_rc.rb
47
+ - spec/spec_suite.rb
48
+ - spec/selenium_rc/server_spec.rb
49
+ - spec/bin_selenium_rc_spec.rb
50
+ - spec/spec_helper.rb
51
+ - vendor/empty.txt
52
+ - vendor/selenium-server.jar
53
+ has_rdoc: true
54
+ homepage: http://github.com/pivotal/selenium-rc
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --charset=UTF-8
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.5
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: The Selenium RC Server packaged as a gem.
81
+ test_files:
82
+ - spec/bin_selenium_rc_spec.rb
83
+ - spec/selenium_rc/server_spec.rb
84
+ - spec/spec_helper.rb
85
+ - spec/spec_suite.rb