selenium-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ lib/selenium_rails/selenium_driver_manager.rb
2
+ lib/selenium_rails/selenium_helper.rb
3
+ lib/selenium_rails/selenium_test_case.rb
4
+ lib/selenium_rails/servers_runner.rb
5
+ lib/selenium_rails.rb
6
+ lib/selenium-rails.rb
7
+ lib/tasks/selenium_tasks.rake
8
+ Manifest
9
+ README.txt
@@ -0,0 +1,18 @@
1
+ = Selenium Rails
2
+
3
+ Copyright:: (c) 2008 Chad Woolley and others
4
+ License:: MIT License
5
+
6
+ Selenium Rails supports the use of Selenium RC with Ruby on Rails projects.
7
+
8
+ = Instructions
9
+
10
+ * gem install selenium-rake
11
+ * Copy the file /lib/tasks/selenium_tasks.rake into your app's lib/tasks directory
12
+ * Write some selenium tests under test/selenium. For an example app, see http://github.com/pivotal/minimalenium
13
+ * 'rake test:selenium' to run all selenium tests
14
+ * 'rake test:selenium TEST=test/selenium/my_test.rb' to run a single test file
15
+
16
+ For documentation on the Selenium Ruby gem, see http://selenium.rubyforge.org/
17
+
18
+ For documentation on the Selenium project and Selenium RC, see the Selenium homepage: http://www.openqa.org/selenium
@@ -0,0 +1,2 @@
1
+ # Allow people to require with a dash as well as an underscore
2
+ require 'selenium_rails'
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'selenium'
3
+ require 'test/unit'
4
+ require 'selenium_rails/selenium_driver_manager'
5
+ require 'selenium_rails/selenium_helper'
6
+ require 'selenium_rails/selenium_test_case'
7
+ require 'selenium_rails/servers_runner'
@@ -0,0 +1,22 @@
1
+ module Selenium
2
+ class SeleniumDriverManager
3
+ @@selenium_driver = nil
4
+
5
+ def self.driver(driver_options = {})
6
+ unless @@selenium_driver
7
+ browser_start_command = ENV['BROWSER_START_COMMAND'] ? ENV['BROWSER_START_COMMAND'] : '*firefox'
8
+ opts = {:server_host => 'localhost', :server_port => '4444', :browser_start_command => browser_start_command,
9
+ :browser_url => 'http://localhost:3001', :timeout => 10000}.merge(driver_options)
10
+ @@selenium_driver = Selenium::SeleniumDriver.new(opts[:server_host], opts[:server_port], opts[:browser_start_command],
11
+ opts[:browser_url], opts[:timeout])
12
+ @@selenium_driver.start
13
+ end
14
+ @@selenium_driver
15
+ end
16
+
17
+ def self.stop_driver
18
+ @@selenium_driver.stop if @@selenium_driver
19
+ @@selenium_driver = nil
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ module Selenium
2
+ module SeleniumHelper
3
+ def browser
4
+ SeleniumDriverManager.driver
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ module Selenium
2
+ class TestCase < Test::Unit::TestCase
3
+ include Selenium::SeleniumHelper
4
+
5
+ def default_test
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,28 @@
1
+ require 'selenium'
2
+ require File.dirname(__FILE__) + '/selenium_driver_manager'
3
+
4
+ module SeleniumRails
5
+ class ServersRunner
6
+ def self.run_with_servers(&block)
7
+ begin
8
+ rails_server_process = IO.popen("ruby #{RAILS_ROOT}/script/server --port=3001 --environment=test")
9
+ selenium_server = Selenium::SeleniumServer.new
10
+ unless selenium_server.running?
11
+ IO.popen("selenium")
12
+ end
13
+
14
+ yield
15
+
16
+ Selenium::SeleniumDriverManager.stop_driver
17
+ rescue Exception => e
18
+ puts e
19
+ raise e
20
+ ensure
21
+ puts "Killing rails server process at pid #{rails_server_process.pid}"
22
+ Process.kill(9,rails_server_process.pid)
23
+ puts "Killing selenium server"
24
+ selenium_server.stop
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # TODO: figure out how to load this from the gem. See http://rails.lighthouseapp.com/projects/8994/tickets/59
2
+ require 'test/unit'
3
+
4
+ namespace :test do
5
+ desc "Run tests for Selenium (automatically starts rails and selenium RC servers)"
6
+ task :selenium do
7
+ require 'rubygems'
8
+ require 'selenium-rails'
9
+
10
+ SeleniumRails::ServersRunner.run_with_servers do
11
+ Rake::Task["test:selenium_with_servers_started"].invoke
12
+ end
13
+ end
14
+
15
+ Rake::TestTask.new(:selenium_with_servers_started) do |t|
16
+ t.pattern = 'test/selenium/**/*_test.rb'
17
+ t.verbose = true
18
+ end
19
+ end
20
+
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = %q{selenium-rails}
3
+ s.version = "0.0.1"
4
+
5
+ s.specification_version = 2 if s.respond_to? :specification_version=
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Chad Woolley, Others"]
9
+ s.date = %q{2008-08-20}
10
+ s.description = %q{Support for using Selenium RC with Rails}
11
+ s.email = %q{thewoolleyman@gmail.com}
12
+ s.extra_rdoc_files = ["lib/selenium_rails/selenium_driver_manager.rb", "lib/selenium_rails/selenium_helper.rb", "lib/selenium_rails/selenium_test_case.rb", "lib/selenium_rails/servers_runner.rb", "lib/selenium_rails.rb", "lib/selenium-rails.rb", "README.txt"]
13
+ s.files = ["lib/selenium_rails/selenium_driver_manager.rb", "lib/selenium_rails/selenium_helper.rb", "lib/selenium_rails/selenium_test_case.rb", "lib/selenium_rails/servers_runner.rb", "lib/selenium_rails.rb", "lib/selenium-rails.rb", "lib/tasks/selenium_tasks.rake", "Manifest", "README.txt", "selenium-rails.gemspec"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://selenium-rails.rubyforge.org}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Selenium Rails", "--main", "README.txt"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{selenium-rails}
19
+ s.rubygems_version = %q{1.2.0}
20
+ s.summary = %q{Support for using Selenium RC with Rails.}
21
+
22
+ s.add_dependency(%q<Selenium>, [">= 1.1.14"])
23
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selenium-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Chad Woolley, Others
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-20 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: Selenium
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.1.14
24
+ version:
25
+ description: Support for using Selenium RC with Rails
26
+ email: thewoolleyman@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - lib/selenium_rails/selenium_driver_manager.rb
33
+ - lib/selenium_rails/selenium_helper.rb
34
+ - lib/selenium_rails/selenium_test_case.rb
35
+ - lib/selenium_rails/servers_runner.rb
36
+ - lib/selenium_rails.rb
37
+ - lib/selenium-rails.rb
38
+ - README.txt
39
+ files:
40
+ - lib/selenium_rails/selenium_driver_manager.rb
41
+ - lib/selenium_rails/selenium_helper.rb
42
+ - lib/selenium_rails/selenium_test_case.rb
43
+ - lib/selenium_rails/servers_runner.rb
44
+ - lib/selenium_rails.rb
45
+ - lib/selenium-rails.rb
46
+ - lib/tasks/selenium_tasks.rake
47
+ - Manifest
48
+ - README.txt
49
+ - selenium-rails.gemspec
50
+ has_rdoc: true
51
+ homepage: http://selenium-rails.rubyforge.org
52
+ post_install_message:
53
+ rdoc_options:
54
+ - --line-numbers
55
+ - --inline-source
56
+ - --title
57
+ - Selenium Rails
58
+ - --main
59
+ - README.txt
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: selenium-rails
77
+ rubygems_version: 1.3.0
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: Support for using Selenium RC with Rails.
81
+ test_files: []
82
+