testingbot 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/LICENSE +1 -1
- data/README.md +137 -0
- data/bin/testingbot +4 -3
- data/lib/testingbot.rb +1 -5
- data/lib/testingbot/api.rb +91 -15
- data/lib/testingbot/version.rb +1 -1
- data/spec/integration/api_spec.rb +21 -15
- data/spec/spec_helper.rb +6 -3
- data/testingbot.gemspec +3 -3
- metadata +7 -52
- data/README.rdoc +0 -237
- data/examples/android.rb +0 -14
- data/examples/capybara.rb +0 -22
- data/examples/capybara_multiple_browsers.rb +0 -38
- data/examples/cucumber/README.rdoc +0 -15
- data/examples/cucumber/Rakefile +0 -20
- data/examples/cucumber/features/support/env.rb +0 -13
- data/examples/cucumber/features/youtube.feature +0 -10
- data/examples/cucumber/features/youtube_steps.rb +0 -15
- data/examples/test_rspec.rb +0 -17
- data/examples/test_rspec1.rb +0 -36
- data/examples/test_unit.rb +0 -30
- data/lib/testingbot/capybara.rb +0 -66
- data/lib/testingbot/config.rb +0 -125
- data/lib/testingbot/cucumber.rb +0 -35
- data/lib/testingbot/hooks.rb +0 -284
- data/lib/testingbot/jasmine.rb +0 -29
- data/lib/testingbot/jasmine/README.rdoc +0 -16
- data/lib/testingbot/jasmine/Rakefile +0 -35
- data/lib/testingbot/jasmine/public/javascripts/Player.js +0 -22
- data/lib/testingbot/jasmine/public/javascripts/Song.js +0 -7
- data/lib/testingbot/jasmine/runner.rb +0 -4
- data/lib/testingbot/jasmine/spec/javascripts/PlayerSpec.js +0 -58
- data/lib/testingbot/jasmine/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/lib/testingbot/jasmine/spec/javascripts/support/jasmine.yml +0 -73
- data/lib/testingbot/jasmine/test/Rakefile +0 -9
- data/lib/testingbot/jasmine/test/public/javascripts/Player.js +0 -22
- data/lib/testingbot/jasmine/test/public/javascripts/Song.js +0 -7
- data/lib/testingbot/jasmine/test/spec/javascripts/PlayerSpec.js +0 -58
- data/lib/testingbot/jasmine/test/spec/javascripts/helpers/SpecHelper.js +0 -9
- data/lib/testingbot/jasmine/test/spec/javascripts/support/jasmine.yml +0 -73
- data/lib/testingbot/selenium.rb +0 -127
- data/lib/testingbot/tunnel.rb +0 -104
- data/spec/integration/selenium1_spec.rb +0 -53
- data/spec/integration/selenium2_spec.rb +0 -60
- data/spec/integration/tunnel_spec.rb +0 -84
- data/spec/unit/api_spec.rb +0 -17
- data/spec/unit/config_spec.rb +0 -73
- data/spec/unit/tunnel_spec.rb +0 -41
- data/vendor/Testingbot-Tunnel.jar +0 -0
data/lib/testingbot/selenium.rb
DELETED
@@ -1,127 +0,0 @@
|
|
1
|
-
# we create our own Selenium classes here to extend them with user credentials and config
|
2
|
-
|
3
|
-
require 'selenium/client'
|
4
|
-
require 'selenium/webdriver'
|
5
|
-
require 'selenium/webdriver/remote/http/persistent'
|
6
|
-
|
7
|
-
module TestingBot
|
8
|
-
|
9
|
-
class SeleniumWebdriver
|
10
|
-
|
11
|
-
attr_reader :config, :driver
|
12
|
-
attr_accessor :session_id_backup
|
13
|
-
|
14
|
-
def initialize(options = {})
|
15
|
-
@options = TestingBot::get_config.options
|
16
|
-
@options = @options.merge(options)
|
17
|
-
|
18
|
-
http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
|
19
|
-
if ENV['TESTINGBOT_CLIENT_PROXY']
|
20
|
-
require 'ostruct'
|
21
|
-
http_client.proxy = OpenStruct.new(:http => ENV['TESTINGBOT_CLIENT_PROXY'])
|
22
|
-
end
|
23
|
-
http_client.timeout = 400
|
24
|
-
@driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@options[:client_key]}:#{@options[:client_secret]}@#{@options[:host]}:#{@options[:port]}/wd/hub", :desired_capabilities => @options[:desired_capabilities], :http_client => http_client)
|
25
|
-
http_client.timeout = 120
|
26
|
-
end
|
27
|
-
|
28
|
-
def method_missing(meth, *args)
|
29
|
-
@driver.send(meth, *args)
|
30
|
-
end
|
31
|
-
|
32
|
-
def session_id
|
33
|
-
@driver.send(:bridge).session_id
|
34
|
-
end
|
35
|
-
|
36
|
-
def stop
|
37
|
-
@session_id_backup = session_id
|
38
|
-
@driver.quit
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# if selenium RC, add testingbot credentials to request
|
44
|
-
if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Protocol)
|
45
|
-
module Selenium
|
46
|
-
module Client
|
47
|
-
module Protocol
|
48
|
-
# add custom parameters for testingbot.com
|
49
|
-
def http_request_for_testingbot(verb, args)
|
50
|
-
raise "Please specify your key and secret in a ~/.testingbot or C:\\.testingbot file" if TestingBot.get_config[:client_key].nil?
|
51
|
-
data = http_request_for_original(verb, args)
|
52
|
-
data << "&client_key=#{TestingBot.get_config[:client_key]}&client_secret=#{TestingBot.get_config[:client_secret]}"
|
53
|
-
end
|
54
|
-
|
55
|
-
begin
|
56
|
-
alias http_request_for_original http_request_for
|
57
|
-
alias http_request_for http_request_for_testingbot
|
58
|
-
rescue
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Base)
|
66
|
-
module Selenium
|
67
|
-
module Client
|
68
|
-
module Base
|
69
|
-
DEFAULT_OPTIONS = {
|
70
|
-
:screenshot => true
|
71
|
-
}
|
72
|
-
|
73
|
-
alias :close_current_browser_session_old :close_current_browser_session
|
74
|
-
alias :start_new_browser_session_old :start_new_browser_session
|
75
|
-
alias :initialize_old :initialize
|
76
|
-
|
77
|
-
attr_accessor :options
|
78
|
-
attr_accessor :session_id_backup
|
79
|
-
attr_accessor :extra
|
80
|
-
attr_accessor :platform
|
81
|
-
attr_accessor :version
|
82
|
-
|
83
|
-
attr_reader :config
|
84
|
-
|
85
|
-
def initialize(*args)
|
86
|
-
@config = TestingBot::get_config
|
87
|
-
@options = @config[:options] || {}
|
88
|
-
|
89
|
-
if args[0].kind_of?(Hash)
|
90
|
-
options = args[0]
|
91
|
-
@platform = options[:platform] || "WINDOWS"
|
92
|
-
@version = options[:version] if options[:version]
|
93
|
-
end
|
94
|
-
|
95
|
-
@options = DEFAULT_OPTIONS
|
96
|
-
initialize_old(*args)
|
97
|
-
@host = options[:host] || @config[:host]
|
98
|
-
@port = options[:port] || @config[:port]
|
99
|
-
end
|
100
|
-
|
101
|
-
def close_current_browser_session
|
102
|
-
@session_id_backup = @session_id
|
103
|
-
close_current_browser_session_old
|
104
|
-
end
|
105
|
-
|
106
|
-
def session_id
|
107
|
-
@session_id || @session_id_backup || ""
|
108
|
-
end
|
109
|
-
|
110
|
-
def start_new_browser_session(options={})
|
111
|
-
options = @options.merge options
|
112
|
-
options[:platform] = @platform
|
113
|
-
options[:version] = @version unless @version.nil?
|
114
|
-
start_new_browser_session_old(options)
|
115
|
-
end
|
116
|
-
|
117
|
-
def extra=(str)
|
118
|
-
@extra = str
|
119
|
-
end
|
120
|
-
|
121
|
-
def options=(opts = {})
|
122
|
-
@options = @options.merge opts
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
data/lib/testingbot/tunnel.rb
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
module TestingBot
|
2
|
-
class Tunnel
|
3
|
-
TIMEOUT_SECONDS = 140
|
4
|
-
|
5
|
-
@@running = false
|
6
|
-
|
7
|
-
attr_reader :options, :config, :process, :available, :connected, :errors
|
8
|
-
|
9
|
-
def initialize(opts = {})
|
10
|
-
@available = false
|
11
|
-
@errors = []
|
12
|
-
@config = TestingBot.get_config
|
13
|
-
@options = default_options
|
14
|
-
@options = @options.merge(opts)
|
15
|
-
|
16
|
-
raise ArgumentError, "Please make sure you have put the .testingbot file in the your user directory, or set the environment variables TESTINGBOT_CLIENTKEY AND TESTINGBOT_CLIENTSECRET" if @config[:client_key].nil? || @config[:client_secret].nil?
|
17
|
-
end
|
18
|
-
|
19
|
-
def start
|
20
|
-
return if @@running == true
|
21
|
-
|
22
|
-
@@running = true
|
23
|
-
|
24
|
-
@config.require_tunnel
|
25
|
-
p "Starting the TestingBot Tunnel" if @options[:verbose] == true
|
26
|
-
@process = IO.popen("exec java -jar #{get_jar_path} #{@options[:client_key] || @config[:client_key]} #{@options[:client_secret] || @config[:client_secret]} #{extra_options} 2>&1")
|
27
|
-
at_exit do
|
28
|
-
@@running = false
|
29
|
-
# make sure we kill the tunnel
|
30
|
-
Process.kill("INT", @process.pid) if @available == true
|
31
|
-
end
|
32
|
-
|
33
|
-
Thread.new do
|
34
|
-
while (line = @process.gets)
|
35
|
-
if line =~ /^You may start your tests/
|
36
|
-
@available = true
|
37
|
-
end
|
38
|
-
|
39
|
-
if line =~ /Exception/ || line =~ /error/
|
40
|
-
@errors << line
|
41
|
-
end
|
42
|
-
|
43
|
-
p line if @options[:verbose] == true
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
poll_ready
|
48
|
-
|
49
|
-
p "You are now ready to start your test" if @options[:verbose] == true
|
50
|
-
end
|
51
|
-
|
52
|
-
def is_connected?
|
53
|
-
@available
|
54
|
-
end
|
55
|
-
|
56
|
-
def errors
|
57
|
-
@errors || []
|
58
|
-
end
|
59
|
-
|
60
|
-
def stop
|
61
|
-
raise "Can't stop tunnel, it has not been started yet" if @process.nil?
|
62
|
-
p "Stopping TestingBot Tunnel" if @options[:verbose] == true
|
63
|
-
|
64
|
-
kill
|
65
|
-
end
|
66
|
-
|
67
|
-
def kill
|
68
|
-
@@running = false
|
69
|
-
@available = false
|
70
|
-
Process.kill("INT", @process.pid)
|
71
|
-
Process.wait
|
72
|
-
end
|
73
|
-
|
74
|
-
def extra_options
|
75
|
-
extra = @options[:options] || []
|
76
|
-
extra.join(" ")
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def default_options
|
82
|
-
{
|
83
|
-
:verbose => true
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def get_jar_path
|
88
|
-
file = File.expand_path(File.dirname(__FILE__) + '/../../vendor/Testingbot-Tunnel.jar')
|
89
|
-
raise RuntimeException, "Could not find TestingBot-Tunnel.jar in vendor directory" unless File.exists?(file)
|
90
|
-
|
91
|
-
file
|
92
|
-
end
|
93
|
-
|
94
|
-
def poll_ready
|
95
|
-
seconds = 0
|
96
|
-
while ((@available == false) && (seconds < TIMEOUT_SECONDS) && @errors.empty?)
|
97
|
-
sleep 1
|
98
|
-
seconds = seconds + 1
|
99
|
-
end
|
100
|
-
|
101
|
-
raise "Could not start Tunnel after #{TIMEOUT_SECONDS} seconds" if !is_connected? && @errors.empty?
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require "uri"
|
2
|
-
require "net/http"
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
@@success = true
|
6
|
-
@@check_api = true
|
7
|
-
|
8
|
-
# disabled until RSpec2 has append_after support
|
9
|
-
# ::RSpec.configuration.after :each do
|
10
|
-
# if @@check_api
|
11
|
-
# api = TestingBot::Api.new
|
12
|
-
# single_test = api.get_single_test(@selenium_driver.session_id)
|
13
|
-
# single_test["success"].should eql(@@success)
|
14
|
-
# single_test["extra"].should eql("just a test")
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
|
18
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
19
|
-
|
20
|
-
describe "Selenium RC test" do
|
21
|
-
|
22
|
-
before(:all) do
|
23
|
-
@selenium_driver = Selenium::Client::Driver.new \
|
24
|
-
:browser => "firefox",
|
25
|
-
:url => "http://testingbot.com",
|
26
|
-
:timeout_in_second => 60,
|
27
|
-
:platform => "WINDOWS",
|
28
|
-
:version => "10"
|
29
|
-
end
|
30
|
-
before(:each) do
|
31
|
-
@selenium_driver.start_new_browser_session({ :extra => "just a test" })
|
32
|
-
end
|
33
|
-
|
34
|
-
after(:each) do
|
35
|
-
@selenium_driver.close_current_browser_session
|
36
|
-
end
|
37
|
-
|
38
|
-
context "Connect and run successfully to the TestingBot Grid with Selenium 1 (RC)" do
|
39
|
-
it "should be able to run an RC test successfully" do
|
40
|
-
@check_api = false
|
41
|
-
@selenium_driver.open "/"
|
42
|
-
@selenium_driver.text?("TestingBot").should be_true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "Check that we report the test status back successfully" do
|
47
|
-
it "should send a success status to TestingBot upon success of the test" do
|
48
|
-
@check_api = true
|
49
|
-
@selenium_driver.open "/"
|
50
|
-
@selenium_driver.text?("TestingBot").should be_true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require "uri"
|
2
|
-
require "net/http"
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
@@success = true
|
6
|
-
@@check_api = true
|
7
|
-
|
8
|
-
# disabled until RSpec2 has append_after support
|
9
|
-
# ::RSpec.configuration.after :each do
|
10
|
-
# if @@check_api
|
11
|
-
# api = TestingBot::Api.new
|
12
|
-
# single_test = api.get_single_test(@selenium_driver.session_id)
|
13
|
-
# single_test["success"].should eql(@@success)
|
14
|
-
# end
|
15
|
-
# end
|
16
|
-
|
17
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
18
|
-
|
19
|
-
|
20
|
-
TestingBot::config do |config|
|
21
|
-
config[:desired_capabilities] = { :browserName => "firefox", :version => 9, :platform => "WINDOWS" }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "Selenium WebDriver test" do
|
25
|
-
|
26
|
-
before(:all) do
|
27
|
-
@selenium_driver = TestingBot::SeleniumWebdriver.new
|
28
|
-
end
|
29
|
-
|
30
|
-
after(:each) do
|
31
|
-
@selenium_driver.stop
|
32
|
-
end
|
33
|
-
|
34
|
-
context "Connect and run successfully to the TestingBot Grid with Selenium 2" do
|
35
|
-
it "should be able to run an RC test successfully" do
|
36
|
-
@check_api = false
|
37
|
-
@selenium_driver.navigate.to "http://testingbot.com"
|
38
|
-
@selenium_driver.title.should match /^Selenium Testing/
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "Selenium WebDriver test API" do
|
44
|
-
|
45
|
-
before(:all) do
|
46
|
-
@selenium_driver = TestingBot::SeleniumWebdriver.new
|
47
|
-
end
|
48
|
-
|
49
|
-
after(:each) do
|
50
|
-
@selenium_driver.stop
|
51
|
-
end
|
52
|
-
|
53
|
-
context "Check that we report the test status back successfully" do
|
54
|
-
it "should send a success status to TestingBot upon success of the test" do
|
55
|
-
@check_api = true
|
56
|
-
@selenium_driver.navigate.to "http://testingbot.com"
|
57
|
-
@selenium_driver.title.should match /^Selenium Testing/
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
-
|
4
|
-
describe "Testingbot Tunnel" do
|
5
|
-
after :each do
|
6
|
-
@tunnel.stop if @tunnel.is_connected?
|
7
|
-
TestingBot.reset_config!
|
8
|
-
end
|
9
|
-
|
10
|
-
context "the tunnel should start and block until it's ready" do
|
11
|
-
it "should successfully start a tunnel connection" do
|
12
|
-
@tunnel = TestingBot::Tunnel.new()
|
13
|
-
@tunnel.start
|
14
|
-
@tunnel.is_connected?.should == true
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should raise an exception when trying to stop a tunnel that has not been started yet" do
|
18
|
-
@tunnel = TestingBot::Tunnel.new()
|
19
|
-
lambda { @tunnel.stop }.should raise_error(RuntimeError, /not been started/)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "the tunnel needs to handle proper credentials" do
|
24
|
-
it "should fail to start a tunnel connection when invalid credentials are supplied" do
|
25
|
-
@tunnel = TestingBot::Tunnel.new({ :client_key => "fake", :client_secret => "bogus" })
|
26
|
-
@tunnel.start
|
27
|
-
@tunnel.is_connected?.should == false
|
28
|
-
@tunnel.errors.should_not be_empty
|
29
|
-
@tunnel.kill
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should try to fetch client_key and client_secret from the ~/.testingbot file when no credentials supplied" do
|
33
|
-
if File.exists?(File.expand_path("~/.testingbot"))
|
34
|
-
@tunnel = TestingBot::Tunnel.new()
|
35
|
-
@tunnel.start
|
36
|
-
@tunnel.is_connected?.should == true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "the tunnel needs to accept extra options" do
|
42
|
-
it "should accept extra options" do
|
43
|
-
if File.exists?(File.expand_path("~/testingbot_ready.txt"))
|
44
|
-
File.delete(File.expand_path("~/testingbot_ready.txt"))
|
45
|
-
end
|
46
|
-
|
47
|
-
File.exists?(File.expand_path("~/testingbot_ready.txt")).should == false
|
48
|
-
|
49
|
-
@tunnel = TestingBot::Tunnel.new({ :options => ['-f ~/testingbot_ready.txt'] })
|
50
|
-
@tunnel.start
|
51
|
-
@tunnel.is_connected?.should == true
|
52
|
-
|
53
|
-
File.exists?(File.expand_path("~/testingbot_ready.txt")).should == true
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "there should only be one instance of a tunnel running" do
|
58
|
-
it "should check before starting that another tunnel is not yet running" do
|
59
|
-
@tunnel = TestingBot::Tunnel.new
|
60
|
-
@tunnel.start
|
61
|
-
@tunnel.is_connected?.should == true
|
62
|
-
|
63
|
-
clone = TestingBot::Tunnel.new
|
64
|
-
clone.start
|
65
|
-
clone.is_connected?.should == false
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should not be possible to stop a tunnel that is not running" do
|
69
|
-
@tunnel = TestingBot::Tunnel.new
|
70
|
-
lambda { @tunnel.stop }.should raise_error(RuntimeError, /^Can't stop tunnel/)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "When running a tunnel config values should be changed" do
|
75
|
-
it "should change the host and port in the config so that we connect to our tunnel instead of to the grid directly" do
|
76
|
-
@tunnel = TestingBot::Tunnel.new
|
77
|
-
@tunnel.start
|
78
|
-
@tunnel.is_connected?.should == true
|
79
|
-
@tunnel.instance_variable_get("@config")[:require_tunnel].should == true
|
80
|
-
@tunnel.instance_variable_get("@config")[:host].should eql("127.0.0.1")
|
81
|
-
@tunnel.instance_variable_get("@config")[:port].should eql(4445)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/spec/unit/api_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../lib/testingbot/config.rb')
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../lib/testingbot/api.rb')
|
4
|
-
|
5
|
-
describe TestingBot::Api do
|
6
|
-
describe "load config" do
|
7
|
-
it "should load the configuration in the constructor" do
|
8
|
-
api = TestingBot::Api.new
|
9
|
-
api.instance_variable_get("@config").should_not be_nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should use the credentials passed in from the constructor, overwriting possible credentials from the config" do
|
13
|
-
api = TestingBot::Api.new({ :client_key => "fake" })
|
14
|
-
api.instance_variable_get("@config")[:client_key].should eql("fake")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|