testingbot 0.0.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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.rdoc +16 -0
- data/Rakefile +1 -0
- data/bin/testingbot +18 -0
- data/examples/test_rspec.rb +34 -0
- data/examples/test_unit.rb +32 -0
- data/lib/testingbot.rb +123 -0
- data/lib/testingbot/version.rb +3 -0
- data/testingbot.gemspec +21 -0
- metadata +67 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
= TestingBot
|
2
|
+
|
3
|
+
Testingbot.com is a website where you can use our cloud based Selenium grid. Test your web applications in various environments/browsers/devices.
|
4
|
+
|
5
|
+
== How to install?
|
6
|
+
|
7
|
+
You can install our testingbot ruby-gem by running "gem install testingbot" on your commandline.
|
8
|
+
|
9
|
+
== Setup
|
10
|
+
|
11
|
+
After you installed the gem you need to run a one part setup.
|
12
|
+
Type testingbot in your commandline and fill in the API key and API secret you obtained on testingbot.com
|
13
|
+
|
14
|
+
== More information
|
15
|
+
|
16
|
+
Get more information on http://www.testingbot.com
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/testingbot
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV.any?
|
4
|
+
api_key, api_secret = ARGV.first.split(':')
|
5
|
+
else
|
6
|
+
|
7
|
+
p "This utility will help you set up your system to use testingbot.com's infrastructure."
|
8
|
+
p "Once you have entered your api key and secret you will be ready to use our grid"
|
9
|
+
|
10
|
+
p "Please enter your testingbot API KEY:"
|
11
|
+
api_key = gets.chomp
|
12
|
+
p "Please enter your testingbot API SECRET:"
|
13
|
+
api_secret = gets.chomp
|
14
|
+
end
|
15
|
+
|
16
|
+
File.open(File.expand_path("~/.testingbot"), 'w') {|f| f.write("#{api_key}:#{api_secret}") }
|
17
|
+
|
18
|
+
p "Your system is now ready to use testingbot.com's grid infrastructure."
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem "rspec", ">=1.2.8"
|
3
|
+
gem "selenium-client", ">=1.2.18"
|
4
|
+
require "selenium/client"
|
5
|
+
require "selenium/rspec/spec_helper"
|
6
|
+
gem "testingbot"
|
7
|
+
require "testingbot"
|
8
|
+
|
9
|
+
describe "People" do
|
10
|
+
attr_reader :selenium_driver
|
11
|
+
alias :page :selenium_driver
|
12
|
+
|
13
|
+
before(:all) do
|
14
|
+
@selenium_driver = Selenium::Client::Driver.new \
|
15
|
+
:host => "localhost",
|
16
|
+
:port => 4444,
|
17
|
+
:browser => "*safari",
|
18
|
+
:url => "http://www.google.com",
|
19
|
+
:timeout_in_second => 60
|
20
|
+
end
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
selenium_driver.start_new_browser_session
|
24
|
+
end
|
25
|
+
|
26
|
+
append_after(:each) do
|
27
|
+
@selenium_driver.close_current_browser_session
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can find Selenium" do
|
31
|
+
page.open "/"
|
32
|
+
page.title.should eql("Google")
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
gem "selenium-client"
|
3
|
+
require "selenium/client"
|
4
|
+
gem 'test-unit'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
gem "testingbot"
|
8
|
+
require "testingbot"
|
9
|
+
|
10
|
+
class ExampleTest < TestingBot::TestCase
|
11
|
+
attr_reader :browser
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@browser = Selenium::Client::Driver.new \
|
15
|
+
:host => "localhost",
|
16
|
+
:port => 4444,
|
17
|
+
:browser => "*safari",
|
18
|
+
:url => "http://www.google.com",
|
19
|
+
:timeout_in_second => 60
|
20
|
+
|
21
|
+
browser.start_new_browser_session
|
22
|
+
end
|
23
|
+
|
24
|
+
def teardown
|
25
|
+
browser.close_current_browser_session
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_page_search
|
29
|
+
browser.open "/"
|
30
|
+
assert_equal "Google", browser.title
|
31
|
+
end
|
32
|
+
end
|
data/lib/testingbot.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
require "testingbot/version"
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module Client
|
5
|
+
module Protocol
|
6
|
+
attr_writer :client_key, :client_secret
|
7
|
+
|
8
|
+
def client_key
|
9
|
+
if @client_key.nil?
|
10
|
+
@client_key, @client_secret = get_testingbot_credentials
|
11
|
+
end
|
12
|
+
@client_key
|
13
|
+
end
|
14
|
+
|
15
|
+
def client_secret
|
16
|
+
if @client_secret.nil?
|
17
|
+
@client_key, @client_secret = get_testingbot_credentials
|
18
|
+
end
|
19
|
+
@client_secret
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_testingbot_credentials
|
23
|
+
if File.exists?(File.expand_path("~/.testingbot"))
|
24
|
+
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
|
25
|
+
str.split(':')
|
26
|
+
else
|
27
|
+
raise "Please run the testingbot install tool first"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# add custom parameters for testingbot.com
|
32
|
+
def http_request_for_testingbot(verb, args)
|
33
|
+
data = http_request_for_original(verb, args)
|
34
|
+
data << "&client_key=#{client_key}&client_secret=#{client_secret}"
|
35
|
+
end
|
36
|
+
|
37
|
+
alias http_request_for_original http_request_for
|
38
|
+
alias http_request_for http_request_for_testingbot
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module Selenium
|
44
|
+
module Client
|
45
|
+
module Base
|
46
|
+
alias :close_current_browser_session_old :close_current_browser_session
|
47
|
+
attr_accessor :session_id_backup
|
48
|
+
|
49
|
+
def close_current_browser_session
|
50
|
+
@session_id_backup = @session_id
|
51
|
+
close_current_browser_session_old
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if defined?(Spec)
|
58
|
+
Spec::Runner.configure do |config|
|
59
|
+
config.prepend_after(:each) do
|
60
|
+
if File.exists?(File.expand_path("~/.testingbot"))
|
61
|
+
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
|
62
|
+
client_key, client_secret = str.split(':')
|
63
|
+
|
64
|
+
params = {
|
65
|
+
"session_id" => @selenium_driver.session_id_backup,
|
66
|
+
"client_key" => client_key,
|
67
|
+
"client_secret" => client_secret,
|
68
|
+
"status_message" => @execution_error,
|
69
|
+
"success" => !actual_failure?,
|
70
|
+
"name" => description.to_s,
|
71
|
+
"kind" => 2
|
72
|
+
}
|
73
|
+
|
74
|
+
url = URI.parse('http://localhost:3000/hq')
|
75
|
+
http = Net::HTTP.new(url.host, url.port)
|
76
|
+
response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if defined?(Test::Unit::TestCase)
|
83
|
+
module TestingBot
|
84
|
+
class TestingBot::TestCase < Test::Unit::TestCase
|
85
|
+
alias :run_teardown_old :run_teardown
|
86
|
+
alias :handle_exception_old :handle_exception
|
87
|
+
|
88
|
+
attr_accessor :exception
|
89
|
+
|
90
|
+
def run_teardown
|
91
|
+
client_key, client_secret = get_testingbot_credentials
|
92
|
+
params = {
|
93
|
+
"session_id" => browser.session_id,
|
94
|
+
"client_key" => client_key,
|
95
|
+
"client_secret" => client_secret,
|
96
|
+
"status_message" => @exception,
|
97
|
+
"success" => passed?,
|
98
|
+
"name" => self.to_s,
|
99
|
+
"kind" => 2
|
100
|
+
}
|
101
|
+
|
102
|
+
url = URI.parse('http://localhost:3000/hq')
|
103
|
+
http = Net::HTTP.new(url.host, url.port)
|
104
|
+
response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
|
105
|
+
run_teardown_old
|
106
|
+
end #def run_teardown
|
107
|
+
|
108
|
+
def handle_exception(e)
|
109
|
+
@exception = e.to_s
|
110
|
+
handle_exception_old(e)
|
111
|
+
end
|
112
|
+
|
113
|
+
def get_testingbot_credentials
|
114
|
+
if File.exists?(File.expand_path("~/.testingbot"))
|
115
|
+
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
|
116
|
+
str.split(':')
|
117
|
+
else
|
118
|
+
raise "Please run the testingbot install tool first"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/testingbot.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "testingbot/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "testingbot"
|
7
|
+
s.version = Testingbot::VERSION
|
8
|
+
s.authors = ["Jochen"]
|
9
|
+
s.email = ["info@testingbot.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = "Ruby Gem to be used with testingbot.com"
|
12
|
+
s.description = "This gem makes using our Selenium grid on testingbot.com easy"
|
13
|
+
|
14
|
+
s.rubyforge_project = "testingbot"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.add_dependency "rspec"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testingbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jochen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &2151951280 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2151951280
|
25
|
+
description: This gem makes using our Selenium grid on testingbot.com easy
|
26
|
+
email:
|
27
|
+
- info@testingbot.com
|
28
|
+
executables:
|
29
|
+
- testingbot
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- README.rdoc
|
36
|
+
- Rakefile
|
37
|
+
- bin/testingbot
|
38
|
+
- examples/test_rspec.rb
|
39
|
+
- examples/test_unit.rb
|
40
|
+
- lib/testingbot.rb
|
41
|
+
- lib/testingbot/version.rb
|
42
|
+
- testingbot.gemspec
|
43
|
+
homepage: ''
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: testingbot
|
63
|
+
rubygems_version: 1.8.8
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Ruby Gem to be used with testingbot.com
|
67
|
+
test_files: []
|