pivotal-selenium-rc 1.2.20090112

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/README.markdown ADDED
@@ -0,0 +1,5 @@
1
+ === selenium-rc ===
2
+
3
+ Ruby wrapper for selenium rc jar. Bundles the selenium-rc jar and provides a binary and rake tasks to manage them.
4
+
5
+ Selenium RC Home Page: http://seleniumhq.org/projects/remote-control/
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require "rubygems"
2
+ require "tmpdir"
3
+ require "fileutils"
4
+ require "open-uri"
5
+ require "zip/zip"
6
+
7
+ # TODO: Disable all rake version:* tasks because they clobber VERSION.yml
8
+ begin
9
+ require 'jeweler'
10
+ Jeweler::Tasks.new do |s|
11
+ s.name = "selenium-rc"
12
+ s.executables = "selenium-rc"
13
+ s.summary = "The Selenium RC Server packaged as a gem."
14
+ s.email = "pivotallabsopensource@googlegroups.com"
15
+ s.homepage = "http://github.com/pivotal/selenium-rc"
16
+ s.description = "The Selenium RC Server packaged as a gem"
17
+ s.authors = ["Pivotal Labs", "Nate Clark", "Brian Takita", "Chad Woolley"]
18
+ s.files = FileList["[A-Z]*", "{bin,generators,lib,spec}/**/*", "vendor/empty.txt"]
19
+ s.extensions << 'Rakefile'
20
+ s.add_dependency "rubyzip"
21
+ end
22
+ rescue LoadError
23
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
24
+ end
25
+
26
+ task :default => [:download_jar_file]
27
+
28
+ desc "Downloads and installs the SeleniumRC jar file from openqa"
29
+ task :download_jar_file do
30
+ project_dir = File.dirname(__FILE__)
31
+ version_data = YAML.load_file("#{project_dir}/VERSION.yml")
32
+ jar_url = version_data[:jar_url]
33
+ uri = URI.parse(jar_url)
34
+
35
+ download_dir = "#{Dir.tmpdir}/#{Time.now.to_i}"
36
+ FileUtils.mkdir_p(download_dir)
37
+ download_path = "#{download_dir}/#{File.basename(jar_url)}"
38
+
39
+ jar_uri = URI.parse(jar_url)
40
+ File.open(download_path, 'wb') do |f|
41
+ f.write(jar_uri.open.read)
42
+ end
43
+ Zip::ZipFile.open(download_path) do |zipfile|
44
+ jar_file_entry = zipfile.entries.find {|file| file.name =~ /selenium-server\.jar$/}
45
+ zipfile.extract(jar_file_entry, "#{project_dir}/vendor/selenium-server.jar")
46
+ end
47
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 2
4
+ :patch: 20090112
5
+ :jar_url: http://release.seleniumhq.org/selenium-remote-control/1.0-beta-2/selenium-remote-control-1.0-beta-2-dist.zip
data/bin/selenium-rc ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ dir = File.dirname(__FILE__)
4
+ require "rubygems"
5
+ require File.expand_path("#{dir}/../lib/selenium_rc")
6
+ SeleniumRC::Server.boot
@@ -0,0 +1,104 @@
1
+ module SeleniumRC
2
+
3
+ class Server
4
+ class << self
5
+ def boot
6
+ new.boot
7
+ end
8
+
9
+ def host
10
+ ENV["SELENIUM_SERVER_HOST"] || "0.0.0.0"
11
+ end
12
+
13
+ def port
14
+ ENV["SELENIUM_SERVER_PORT"] || "4444"
15
+ end
16
+
17
+ def timeout
18
+ ENV["SELENIUM_SERVER_TIMEOUT"] || 15
19
+ end
20
+
21
+ def service_is_running?
22
+ begin
23
+ socket = TCPSocket.new(host, port)
24
+ socket.close unless socket.nil?
25
+ true
26
+ rescue Errno::ECONNREFUSED,
27
+ Errno::EBADF # Windows
28
+ false
29
+ end
30
+ end
31
+ end
32
+
33
+ def boot
34
+ start
35
+ wait
36
+ stop_at_exit
37
+ end
38
+
39
+ def start
40
+ command = "java -jar \"#{jar_path}\""
41
+ command << " -port #{self.class.port}"
42
+ command << " -timeout #{self.class.timeout}"
43
+ puts "Running: #{command}"
44
+ system(command)
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=shutDown', port)
74
+ end
75
+
76
+ def host
77
+ self.class.host
78
+ end
79
+
80
+ def port
81
+ self.class.port
82
+ end
83
+
84
+ def timeout
85
+ self.class.timeout
86
+ end
87
+
88
+ def service_is_running?
89
+ self.class.service_is_running?
90
+ end
91
+
92
+ protected
93
+ def wait_for_service_with_timeout
94
+ start_time = Time.now
95
+
96
+ until self.class.service_is_running?
97
+ if timeout && (Time.now > (start_time + timeout))
98
+ raise SocketError.new("Socket did not open within #{timeout} seconds")
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ end
@@ -0,0 +1,3 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "socket"
3
+ require "#{dir}/selenium_rc/server"
@@ -0,0 +1,31 @@
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
+ after do
14
+ system("lsof -i tcp:4444 | grep '(LISTEN)' | awk '{print $2}' | xargs kill -9")
15
+ TCPSocket.wait_for_service_termination(:host => "0.0.0.0", :port => 4444)
16
+ end
17
+
18
+ it "starts the SeleniumRC server from the downloaded jar file" do
19
+ Dir.chdir(root_dir) do
20
+ system("bin/selenium-rc &") || raise("bin/selenium-server failed")
21
+ end
22
+
23
+ start_time = Time.now
24
+ timeout = 15
25
+ until SeleniumRC::Server.service_is_running?
26
+ if Time.now > (start_time + timeout)
27
+ raise SocketError.new("Socket did not open within #{timeout} seconds")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ require "rubygems"
2
+ require "spec"
3
+ require "spec/autorun"
4
+ require "fileutils"
5
+ require "timeout"
6
+ require "tcp_socket_extension"
7
+
8
+ dir = File.dirname(__FILE__)
9
+ $:.unshift(File.expand_path("#{dir}/../lib"))
10
+ require "selenium_rc"
11
+
12
+ Spec::Runner.configure do |config|
13
+ 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
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pivotal-selenium-rc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.20090112
5
+ platform: ruby
6
+ authors:
7
+ - Pivotal Labs
8
+ - Nate Clark
9
+ - Brian Takita
10
+ - Chad Woolley
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+
15
+ date: 2009-05-11 00:00:00 -07:00
16
+ default_executable: selenium-rc
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: rubyzip
20
+ type: :runtime
21
+ version_requirement:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: "0"
27
+ version:
28
+ description: The Selenium RC Server packaged as a gem
29
+ email: pivotallabsopensource@googlegroups.com
30
+ executables:
31
+ - selenium-rc
32
+ extensions:
33
+ - Rakefile
34
+ extra_rdoc_files:
35
+ - README.markdown
36
+ files:
37
+ - README.markdown
38
+ - Rakefile
39
+ - VERSION.yml
40
+ - bin/selenium-rc
41
+ - lib/selenium_rc.rb
42
+ - lib/selenium_rc/server.rb
43
+ - spec/install_and_run_spec.rb
44
+ - spec/spec_helper.rb
45
+ - spec/spec_suite.rb
46
+ - vendor/empty.txt
47
+ has_rdoc: true
48
+ homepage: http://github.com/pivotal/selenium-rc
49
+ post_install_message:
50
+ rdoc_options:
51
+ - --charset=UTF-8
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 2
72
+ summary: The Selenium RC Server packaged as a gem.
73
+ test_files:
74
+ - spec/install_and_run_spec.rb
75
+ - spec/spec_suite.rb
76
+ - spec/spec_helper.rb