testingbot 0.0.8 → 0.0.9
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.rdoc +8 -4
- data/bin/testingbot +0 -0
- data/examples/cucumber/features/support/env.rb +31 -13
- data/lib/testingbot.rb +14 -43
- data/lib/testingbot/config.rb +66 -0
- data/lib/testingbot/cucumber.rb +25 -21
- data/lib/testingbot/version.rb +1 -1
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -32,7 +32,7 @@ You can find an example in our examples folder, try something like this:
|
|
32
32
|
:url => "http://www.google.com",
|
33
33
|
:platform => "WINDOWS",
|
34
34
|
:version => 10,
|
35
|
-
:timeout_in_second =>
|
35
|
+
:timeout_in_second => 90
|
36
36
|
|
37
37
|
browser.options = {
|
38
38
|
:screenshot => true
|
@@ -67,7 +67,7 @@ This example uses RSpec 2. You can run it with rspec test_rspec.rb
|
|
67
67
|
:port => 4444,
|
68
68
|
:browser => "firefox",
|
69
69
|
:url => "http://www.google.com",
|
70
|
-
:timeout_in_second =>
|
70
|
+
:timeout_in_second => 90,
|
71
71
|
:platform => "WINDOWS",
|
72
72
|
:version => "10"
|
73
73
|
end
|
@@ -107,7 +107,7 @@ This example uses RSpec 1. You can run it with spec test_rspec1.rb
|
|
107
107
|
:port => 4444,
|
108
108
|
:browser => "firefox",
|
109
109
|
:url => "http://www.google.com",
|
110
|
-
:timeout_in_second =>
|
110
|
+
:timeout_in_second => 90,
|
111
111
|
:platform => "WINDOWS",
|
112
112
|
:version => "10"
|
113
113
|
end
|
@@ -162,6 +162,10 @@ This example uses RSpec 2 together with capybara and Selenium webdriver. You can
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
+
== Capybara and Cucumber
|
166
|
+
The examples directory contains an example of testing with Capybara and Cucumber
|
167
|
+
More info available on http://testingbot.com/support/getting-started/cucumber.html
|
168
|
+
|
165
169
|
== Extra options
|
166
170
|
You can specify extra options like enabling/disabling the screenrecording or screenshot feature. (browser.options)
|
167
171
|
|
@@ -170,7 +174,7 @@ For example a build number, or other custom data. (browser.extra = "")
|
|
170
174
|
|
171
175
|
== More information
|
172
176
|
|
173
|
-
Get more information on http://
|
177
|
+
Get more information on http://testingbot.com
|
174
178
|
|
175
179
|
== Copyright
|
176
180
|
|
data/bin/testingbot
CHANGED
File without changes
|
@@ -4,17 +4,35 @@ require 'rspec'
|
|
4
4
|
require 'selenium/webdriver'
|
5
5
|
require 'testingbot/cucumber'
|
6
6
|
|
7
|
-
|
8
|
-
caps
|
9
|
-
caps
|
7
|
+
if ENV['TESTINGBOT_BROWSER']
|
8
|
+
caps = {}
|
9
|
+
caps[:browser] = ENV['TESTINGBOT_BROWSER']
|
10
|
+
caps[:version] = ENV['TESTINGBOT_BROWSERVERSION'] || ""
|
11
|
+
caps[:platform] = ENV['TESTINGBOT_BROWSEROS'] || :WINDOWS
|
10
12
|
|
11
|
-
Capybara.default_driver = :testingbot
|
12
|
-
Capybara.register_driver :testingbot do |app|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
13
|
+
Capybara.default_driver = :testingbot
|
14
|
+
Capybara.register_driver :testingbot do |app|
|
15
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
16
|
+
client.timeout = 120
|
17
|
+
Capybara::Selenium::Driver.new(app,
|
18
|
+
:browser => :remote,
|
19
|
+
:url => "http://251ca561ab0f7557bb34c3ee3dbde285:3fc22e44f086fa036d8b01eadf66740b@hub.testingbot.com:4444/wd/hub",
|
20
|
+
:http_client => client,
|
21
|
+
:desired_capabilities => caps)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
caps = Selenium::WebDriver::Remote::Capabilities.firefox
|
25
|
+
caps.version = "10"
|
26
|
+
caps.platform = :WINDOWS
|
27
|
+
|
28
|
+
Capybara.default_driver = :testingbot
|
29
|
+
Capybara.register_driver :testingbot do |app|
|
30
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
31
|
+
client.timeout = 120
|
32
|
+
Capybara::Selenium::Driver.new(app,
|
33
|
+
:browser => :remote,
|
34
|
+
:url => "http://251ca561ab0f7557bb34c3ee3dbde285:3fc22e44f086fa036d8b01eadf66740b@hub.testingbot.com:4444/wd/hub",
|
35
|
+
:http_client => client,
|
36
|
+
:desired_capabilities => caps)
|
37
|
+
end
|
38
|
+
end
|
data/lib/testingbot.rb
CHANGED
@@ -1,39 +1,15 @@
|
|
1
1
|
require "testingbot/version"
|
2
|
+
require "testingbot/config"
|
2
3
|
|
3
4
|
# if selenium RC, add testingbot credentials to request
|
4
5
|
if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Protocol)
|
5
6
|
module Selenium
|
6
7
|
module Client
|
7
8
|
module Protocol
|
8
|
-
attr_writer :client_key, :client_secret
|
9
|
-
|
10
|
-
def client_key
|
11
|
-
if @client_key.nil?
|
12
|
-
@client_key, @client_secret = get_testingbot_credentials
|
13
|
-
end
|
14
|
-
@client_key
|
15
|
-
end
|
16
|
-
|
17
|
-
def client_secret
|
18
|
-
if @client_secret.nil?
|
19
|
-
@client_key, @client_secret = get_testingbot_credentials
|
20
|
-
end
|
21
|
-
@client_secret
|
22
|
-
end
|
23
|
-
|
24
|
-
def get_testingbot_credentials
|
25
|
-
if File.exists?(File.expand_path("~/.testingbot"))
|
26
|
-
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
|
27
|
-
str.split(':')
|
28
|
-
else
|
29
|
-
raise "Please run the testingbot install tool first"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
9
|
# add custom parameters for testingbot.com
|
34
10
|
def http_request_for_testingbot(verb, args)
|
35
11
|
data = http_request_for_original(verb, args)
|
36
|
-
data << "&client_key=#{client_key}&client_secret=#{client_secret}"
|
12
|
+
data << "&client_key=#{TestingBot.get_config[:client_key]}&client_secret=#{TestingBot.get_config[:client_secret]}"
|
37
13
|
end
|
38
14
|
|
39
15
|
begin
|
@@ -107,9 +83,10 @@ begin
|
|
107
83
|
require "selenium/rspec/spec_helper"
|
108
84
|
Spec::Runner.configure do |config|
|
109
85
|
config.prepend_after(:each) do
|
110
|
-
|
111
|
-
|
112
|
-
|
86
|
+
client_key = TestingBot.get_config[:client_key]
|
87
|
+
client_secret = TestingBot.get_config[:client_secret]
|
88
|
+
|
89
|
+
if !client_key.nil?
|
113
90
|
|
114
91
|
session_id = nil
|
115
92
|
|
@@ -152,10 +129,11 @@ begin
|
|
152
129
|
require 'rspec'
|
153
130
|
|
154
131
|
::RSpec.configuration.after :each do
|
155
|
-
if File.exists?(File.expand_path("~/.testingbot"))
|
156
|
-
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
|
157
|
-
client_key, client_secret = str.split(':')
|
158
132
|
|
133
|
+
client_key = TestingBot.get_config[:client_key]
|
134
|
+
client_secret = TestingBot.get_config[:client_secret]
|
135
|
+
|
136
|
+
if !client_key.nil?
|
159
137
|
test_name = ""
|
160
138
|
if example.metadata && example.metadata[:example_group]
|
161
139
|
if example.metadata[:example_group][:description_args]
|
@@ -208,7 +186,7 @@ begin
|
|
208
186
|
rescue LoadError
|
209
187
|
end
|
210
188
|
|
211
|
-
if defined?(Test::Unit::TestCase)
|
189
|
+
if defined?(Test::Unit::TestCase) && (Test::Unit::TestCase.respond_to?('run_teardown'))
|
212
190
|
module TestingBot
|
213
191
|
class TestingBot::TestCase < Test::Unit::TestCase
|
214
192
|
alias :run_teardown_old :run_teardown
|
@@ -217,7 +195,9 @@ if defined?(Test::Unit::TestCase)
|
|
217
195
|
attr_accessor :exception
|
218
196
|
|
219
197
|
def run_teardown
|
220
|
-
client_key
|
198
|
+
client_key = TestingBot.get_config[:client_key]
|
199
|
+
client_secret = TestingBot.get_config[:client_secret]
|
200
|
+
|
221
201
|
params = {
|
222
202
|
"session_id" => browser.session_id,
|
223
203
|
"client_key" => client_key,
|
@@ -239,15 +219,6 @@ if defined?(Test::Unit::TestCase)
|
|
239
219
|
@exception = e.to_s
|
240
220
|
handle_exception_old(e)
|
241
221
|
end
|
242
|
-
|
243
|
-
def get_testingbot_credentials
|
244
|
-
if File.exists?(File.expand_path("~/.testingbot"))
|
245
|
-
str = File.open(File.expand_path("~/.testingbot")) { |f| f.readline }.chomp
|
246
|
-
str.split(':')
|
247
|
-
else
|
248
|
-
raise "Please run the testingbot install tool first"
|
249
|
-
end
|
250
|
-
end
|
251
222
|
end
|
252
223
|
end
|
253
224
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module TestingBot
|
2
|
+
@@config = nil
|
3
|
+
|
4
|
+
def self.get_config
|
5
|
+
@@config = TestingBot::Config.new if @@config.nil?
|
6
|
+
@@config
|
7
|
+
end
|
8
|
+
|
9
|
+
class Config
|
10
|
+
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
@options = options
|
15
|
+
@options = @options.merge(load_config_file)
|
16
|
+
@options = @options.merge(load_config_environment)
|
17
|
+
end
|
18
|
+
|
19
|
+
def [](key)
|
20
|
+
@options[key]
|
21
|
+
end
|
22
|
+
|
23
|
+
def []=(key, value)
|
24
|
+
@options[key] = value
|
25
|
+
end
|
26
|
+
|
27
|
+
def client_key
|
28
|
+
@options[:client_key]
|
29
|
+
end
|
30
|
+
|
31
|
+
def client_secret
|
32
|
+
@options[:client_secret]
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def load_config_file
|
38
|
+
options = {}
|
39
|
+
|
40
|
+
is_windows = (RUBY_PLATFORM =~ /w.*32/)
|
41
|
+
|
42
|
+
if is_windows
|
43
|
+
config_file = "#{ENV['HOMEDRIVE']}\\.testingbot"
|
44
|
+
else
|
45
|
+
config_file = File.expand_path("~/.testingbot")
|
46
|
+
end
|
47
|
+
|
48
|
+
if File.exists?(config_file)
|
49
|
+
str = File.open(config_file) { |f| f.readline }.chomp
|
50
|
+
options[:client_key], options[:client_secret] = str.split(':')
|
51
|
+
end
|
52
|
+
|
53
|
+
options
|
54
|
+
end
|
55
|
+
|
56
|
+
def load_config_environment
|
57
|
+
options = {}
|
58
|
+
options[:client_key] = ENV['TESTINGBOT_CLIENTKEY']
|
59
|
+
options[:client_secret] = ENV['TESTINGBOT_CLIENTSECRET']
|
60
|
+
|
61
|
+
options.delete_if { |key, value| value.nil?}
|
62
|
+
|
63
|
+
options
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/testingbot/cucumber.rb
CHANGED
@@ -1,26 +1,30 @@
|
|
1
|
+
require 'testingbot/config'
|
2
|
+
|
1
3
|
if defined?(Cucumber)
|
2
4
|
After do |scenario|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
5
|
+
client_key = TestingBot.get_config[:client_key]
|
6
|
+
client_secret = TestingBot.get_config[:client_secret]
|
7
|
+
|
8
|
+
if Capybara.drivers.include?(:testingbot) && !TestingBot.get_config[:client_key].nil?
|
9
|
+
begin
|
10
|
+
session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
|
11
|
+
|
12
|
+
params = {
|
13
|
+
"session_id" => session_id,
|
14
|
+
"client_key" => client_key,
|
15
|
+
"client_secret" => client_secret,
|
16
|
+
"status_message" => (scenario.failed? ? scenario.exception.message : ""),
|
17
|
+
"success" => !scenario.failed?,
|
18
|
+
"name" => scenario.title,
|
19
|
+
"kind" => 2
|
20
|
+
}
|
21
|
+
|
22
|
+
url = URI.parse('http://testingbot.com/hq')
|
23
|
+
http = Net::HTTP.new(url.host, url.port)
|
24
|
+
response = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
|
25
|
+
rescue Exception => e
|
26
|
+
p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
data/lib/testingbot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testingbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This gem makes using our Selenium grid on testingbot.com easy
|
15
15
|
email:
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- examples/test_rspec1.rb
|
35
35
|
- examples/test_unit.rb
|
36
36
|
- lib/testingbot.rb
|
37
|
+
- lib/testingbot/config.rb
|
37
38
|
- lib/testingbot/cucumber.rb
|
38
39
|
- lib/testingbot/tunnel.rb
|
39
40
|
- lib/testingbot/version.rb
|