testingbot 0.1.5 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +26 -0
- data/.travis.yml +7 -3
- data/LICENSE +1 -1
- data/README.md +207 -0
- data/bin/testingbot +4 -3
- data/lib/testingbot.rb +1 -5
- data/lib/testingbot/api.rb +153 -35
- data/lib/testingbot/version.rb +1 -1
- data/spec/integration/api_spec.rb +38 -18
- data/spec/resources/test.apk +1 -0
- data/spec/spec_helper.rb +6 -3
- metadata +55 -94
- 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 -287
- 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/testingbot.gemspec +0 -25
- data/vendor/Testingbot-Tunnel.jar +0 -0
data/lib/testingbot/hooks.rb
DELETED
@@ -1,287 +0,0 @@
|
|
1
|
-
# rspec 1
|
2
|
-
if defined?(Spec) && defined?(Spec::VERSION::MAJOR) && Spec::VERSION::MAJOR == 1
|
3
|
-
require "selenium/rspec/spec_helper"
|
4
|
-
Spec::Runner.configure do |config|
|
5
|
-
config.before(:suite) do
|
6
|
-
if TestingBot.get_config[:require_tunnel]
|
7
|
-
@@tunnel = TestingBot::Tunnel.new(TestingBot.get_config[:tunnel_options] || {})
|
8
|
-
@@tunnel.start
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
config.after(:suite) do
|
13
|
-
@@tunnel.stop if defined? @@tunnel
|
14
|
-
end
|
15
|
-
|
16
|
-
config.prepend_after(:each) do
|
17
|
-
client_key = TestingBot.get_config[:client_key]
|
18
|
-
client_secret = TestingBot.get_config[:client_secret]
|
19
|
-
|
20
|
-
if !client_key.nil?
|
21
|
-
|
22
|
-
session_id = nil
|
23
|
-
|
24
|
-
if !@selenium_driver.nil?
|
25
|
-
session_id = @selenium_driver.session_id_backup
|
26
|
-
elsif defined?(Capybara)
|
27
|
-
begin
|
28
|
-
if page.driver.browser.respond_to?(:session_id)
|
29
|
-
session_id = page.driver.browser.session_id
|
30
|
-
else
|
31
|
-
session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
|
32
|
-
end
|
33
|
-
rescue Exception => e
|
34
|
-
puts "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if !session_id.nil?
|
39
|
-
api = TestingBot::Api.new
|
40
|
-
params = {
|
41
|
-
"session_id" => session_id,
|
42
|
-
"status_message" => @execution_error,
|
43
|
-
"success" => !actual_failure? ? 1 : 0,
|
44
|
-
"name" => description.to_s,
|
45
|
-
"kind" => 2
|
46
|
-
}
|
47
|
-
|
48
|
-
begin
|
49
|
-
data = api.update_test(session_id, params)
|
50
|
-
rescue
|
51
|
-
end
|
52
|
-
|
53
|
-
if ENV['JENKINS_HOME'] && (TestingBot.get_config[:jenkins_output] == true)
|
54
|
-
puts "TestingBotSessionID=" + session_id
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
puts "Can't post test results to TestingBot since I could not find a .testingbot file in your home-directory."
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# rspec 2
|
65
|
-
begin
|
66
|
-
require 'rspec'
|
67
|
-
|
68
|
-
::RSpec.configuration.before :suite do
|
69
|
-
if TestingBot.get_config[:require_tunnel]
|
70
|
-
@@tunnel = TestingBot::Tunnel.new(TestingBot.get_config[:tunnel_options] || {})
|
71
|
-
@@tunnel.start
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
module TestingBot
|
76
|
-
module RSpecInclude
|
77
|
-
attr_reader :selenium_driver
|
78
|
-
alias_method :page, :selenium_driver
|
79
|
-
|
80
|
-
def self.included(base)
|
81
|
-
base.around do |test|
|
82
|
-
if TestingBot.get_config.desired_capabilities.instance_of?(Array)
|
83
|
-
TestingBot.get_config.desired_capabilities.each do |browser|
|
84
|
-
|
85
|
-
if defined?(Capybara)
|
86
|
-
::Capybara.register_driver :multibrowser do |app|
|
87
|
-
TestingBot::Capybara::CustomDriver.new(app, { :desired_capabilities => browser })
|
88
|
-
end
|
89
|
-
|
90
|
-
@selenium_driver = ::Capybara::Session.new(:multibrowser)
|
91
|
-
else
|
92
|
-
@selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => browser })
|
93
|
-
end
|
94
|
-
|
95
|
-
begin
|
96
|
-
test.run
|
97
|
-
ensure
|
98
|
-
@selenium_driver.stop
|
99
|
-
end
|
100
|
-
end
|
101
|
-
else
|
102
|
-
if defined?(Capybara)
|
103
|
-
@selenium_driver = ::Capybara::Session.new(:testingbot)
|
104
|
-
else
|
105
|
-
@selenium_driver = TestingBot::SeleniumWebdriver.new({ :desired_capabilities => TestingBot.get_config.desired_capabilities })
|
106
|
-
end
|
107
|
-
begin
|
108
|
-
test.run
|
109
|
-
ensure
|
110
|
-
@selenium_driver.stop
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
module RSpecIncludeLegacy
|
118
|
-
attr_reader :selenium_driver
|
119
|
-
alias_method :page, :selenium_driver
|
120
|
-
|
121
|
-
def self.included(base)
|
122
|
-
base.around do |test|
|
123
|
-
if TestingBot.get_config.desired_capabilities.instance_of?(Array)
|
124
|
-
TestingBot.get_config.desired_capabilities.each do |browser|
|
125
|
-
@selenium_driver = ::Selenium::Client::Driver.new(:browser => browser[:browserName], :url => TestingBot.get_config[:browserUrl])
|
126
|
-
@selenium_driver.start_new_browser_session(browser)
|
127
|
-
begin
|
128
|
-
test.run
|
129
|
-
ensure
|
130
|
-
@selenium_driver.stop
|
131
|
-
end
|
132
|
-
end
|
133
|
-
else
|
134
|
-
@selenium_driver = ::Selenium::Client::Driver.new(:browser => browser[:browserName], :url => TestingBot.get_config[:browserUrl])
|
135
|
-
@selenium_driver.start_new_browser_session(TestingBot.get_config.desired_capabilities)
|
136
|
-
begin
|
137
|
-
test.run
|
138
|
-
ensure
|
139
|
-
@selenium_driver.stop
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
::RSpec.configuration.include(TestingBot::RSpecIncludeLegacy, :multibrowserRC => true)
|
148
|
-
::RSpec.configuration.include(TestingBot::RSpecInclude, :multibrowser => true)
|
149
|
-
|
150
|
-
::RSpec.configuration.after :suite do
|
151
|
-
@@tunnel.stop if defined? @@tunnel
|
152
|
-
end
|
153
|
-
|
154
|
-
::RSpec.configuration.after :each do
|
155
|
-
client_key = TestingBot.get_config[:client_key]
|
156
|
-
client_secret = TestingBot.get_config[:client_secret]
|
157
|
-
|
158
|
-
if !client_key.nil?
|
159
|
-
test_name = ""
|
160
|
-
if example.metadata && example.metadata[:example_group]
|
161
|
-
if example.metadata[:example_group][:description_args]
|
162
|
-
test_name = example.metadata[:example_group][:description_args].join(" ")
|
163
|
-
end
|
164
|
-
|
165
|
-
if example.metadata[:description_args]
|
166
|
-
test_name = test_name + " it " + example.metadata[:description_args].join(" ")
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
status_message = ""
|
171
|
-
status_message = example.exception.to_s if !example.exception.nil?
|
172
|
-
|
173
|
-
session_id = nil
|
174
|
-
|
175
|
-
if !@selenium_driver.nil?
|
176
|
-
session_id = @selenium_driver.session_id
|
177
|
-
elsif defined? page
|
178
|
-
begin
|
179
|
-
if page.driver.browser.respond_to?(:session_id)
|
180
|
-
session_id = page.driver.browser.session_id
|
181
|
-
else
|
182
|
-
session_id = page.driver.browser.instance_variable_get("@bridge").instance_variable_get("@session_id")
|
183
|
-
end
|
184
|
-
rescue Exception => e
|
185
|
-
p "Could not determine sessionID, can not send results to TestingBot.com #{e.message}"
|
186
|
-
end
|
187
|
-
|
188
|
-
if session_id.nil? || session_id.empty?
|
189
|
-
begin
|
190
|
-
session_id = page.driver.browser.send(:bridge).session_id
|
191
|
-
rescue
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
if !session_id.nil?
|
197
|
-
if ENV['JENKINS_HOME'] && (TestingBot.get_config[:jenkins_output] == true)
|
198
|
-
puts "TestingBotSessionID=" + session_id
|
199
|
-
end
|
200
|
-
api = TestingBot::Api.new
|
201
|
-
params = {
|
202
|
-
"session_id" => session_id,
|
203
|
-
"status_message" => status_message,
|
204
|
-
"success" => example.exception.nil? ? 1 : 0,
|
205
|
-
"name" => test_name,
|
206
|
-
"kind" => 2
|
207
|
-
}
|
208
|
-
|
209
|
-
begin
|
210
|
-
data = api.update_test(session_id, params)
|
211
|
-
rescue
|
212
|
-
end
|
213
|
-
end
|
214
|
-
else
|
215
|
-
puts "Can't post test results to TestingBot since I could not find a .testingbot file in your home-directory."
|
216
|
-
end
|
217
|
-
end
|
218
|
-
rescue LoadError
|
219
|
-
end
|
220
|
-
|
221
|
-
module TestingBot
|
222
|
-
module SeleniumForTestUnit
|
223
|
-
attr_accessor :exception
|
224
|
-
attr_reader :browser
|
225
|
-
|
226
|
-
def run(*args, &blk)
|
227
|
-
return if @method_name.to_s == "default_test"
|
228
|
-
if TestingBot.get_config.desired_capabilities.instance_of?(Array)
|
229
|
-
TestingBot.get_config.desired_capabilities.each do |browser|
|
230
|
-
@browser = ::Selenium::Client::Driver.new(:browser => browser[:browserName], :url => TestingBot.get_config[:browserUrl])
|
231
|
-
@browser.start_new_browser_session(browser)
|
232
|
-
super(*args, &blk)
|
233
|
-
@browser.stop
|
234
|
-
end
|
235
|
-
else
|
236
|
-
super(*args, &blk)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
def teardown
|
241
|
-
return super if @browser.nil?
|
242
|
-
api = TestingBot::Api.new
|
243
|
-
params = {
|
244
|
-
"session_id" => @browser.session_id,
|
245
|
-
"status_message" => @exception || "",
|
246
|
-
"success" => passed? ? 1 : 0,
|
247
|
-
"name" => self.to_s,
|
248
|
-
"kind" => 2
|
249
|
-
}
|
250
|
-
|
251
|
-
begin
|
252
|
-
data = api.update_test(@browser.session_id, params)
|
253
|
-
rescue
|
254
|
-
end
|
255
|
-
|
256
|
-
if ENV['JENKINS_HOME'] && (TestingBot.get_config[:jenkins_output] == true)
|
257
|
-
puts "TestingBotSessionID=" + @browser.session_id
|
258
|
-
end
|
259
|
-
super
|
260
|
-
end
|
261
|
-
|
262
|
-
def handle_exception(e)
|
263
|
-
@exception = e.to_s
|
264
|
-
handle_exception_old(e)
|
265
|
-
end
|
266
|
-
|
267
|
-
alias :handle_exception_old :handle_exception
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
begin
|
272
|
-
require 'test/unit/testcase'
|
273
|
-
module TestingBot
|
274
|
-
class TestCase < Test::Unit::TestCase
|
275
|
-
include SeleniumForTestUnit
|
276
|
-
end
|
277
|
-
end
|
278
|
-
rescue LoadError
|
279
|
-
end
|
280
|
-
|
281
|
-
if defined?(ActiveSupport::TestCase)
|
282
|
-
module TestingBot
|
283
|
-
class RailsTestCase < ::ActiveSupport::TestCase
|
284
|
-
include SeleniumForTestUnit
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|
data/lib/testingbot/jasmine.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'jasmine'
|
2
|
-
require 'testingbot/tunnel'
|
3
|
-
|
4
|
-
module TestingBot
|
5
|
-
module Jasmine
|
6
|
-
|
7
|
-
class Driver < ::Jasmine::SeleniumDriver
|
8
|
-
attr_reader :http_address, :driver, :browser
|
9
|
-
|
10
|
-
def initialize(browser, http_address)
|
11
|
-
tunnel = TestingBot::Tunnel.new(TestingBot.get_config[:tunnel_options] || {})
|
12
|
-
tunnel.start
|
13
|
-
|
14
|
-
@browser = browser
|
15
|
-
@http_address = http_address
|
16
|
-
@driver = TestingBot::SeleniumWebdriver.new({ :browserName => browser, :name => "Jasmine Test" })
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Jasmine
|
23
|
-
class Config
|
24
|
-
def start
|
25
|
-
@client = TestingBot::Jasmine::Driver.new(browser, "#{jasmine_host}:3001/")
|
26
|
-
@client.connect
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,16 +0,0 @@
|
|
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 run a Jasmine test on TestingBot
|
6
|
-
|
7
|
-
Make sure you have the Jasmine gem installed
|
8
|
-
|
9
|
-
$ gem install jasmine
|
10
|
-
|
11
|
-
Now run our example Rake task:
|
12
|
-
$ rake jasmine:testingbot
|
13
|
-
|
14
|
-
== More information
|
15
|
-
|
16
|
-
Get more information on http://testingbot.com
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'jasmine'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
require 'testingbot'
|
4
|
-
|
5
|
-
namespace :jasmine do
|
6
|
-
def run_jasmine_server
|
7
|
-
ENV['JASMINE_PORT'] = '3001'
|
8
|
-
Jasmine::Config.new.start_jasmine_server
|
9
|
-
end
|
10
|
-
|
11
|
-
desc "Execute Jasmine tests in a Chrome browser on testingbot"
|
12
|
-
task :testingbot do
|
13
|
-
run_jasmine_server
|
14
|
-
Rake::Task['jasmine:testingbot:chrome'].execute
|
15
|
-
end
|
16
|
-
|
17
|
-
namespace :testingbot do
|
18
|
-
desc "Execute Jasmine tests in Chrome and Firefox on TestingBot"
|
19
|
-
task :all do
|
20
|
-
run_jasmine_server
|
21
|
-
threads = []
|
22
|
-
[:chrome, :firefox].each do |browser|
|
23
|
-
t = Thread.new do
|
24
|
-
Rake::Task["jasmine:testingbot:#{browser}"].invoke
|
25
|
-
end
|
26
|
-
t.abort_on_exception = true
|
27
|
-
threads << t
|
28
|
-
end
|
29
|
-
|
30
|
-
threads.each do |t|
|
31
|
-
t.join
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
function Player() {
|
2
|
-
}
|
3
|
-
Player.prototype.play = function(song) {
|
4
|
-
this.currentlyPlayingSong = song;
|
5
|
-
this.isPlaying = true;
|
6
|
-
};
|
7
|
-
|
8
|
-
Player.prototype.pause = function() {
|
9
|
-
this.isPlaying = false;
|
10
|
-
};
|
11
|
-
|
12
|
-
Player.prototype.resume = function() {
|
13
|
-
if (this.isPlaying) {
|
14
|
-
throw new Error("song is already playing");
|
15
|
-
}
|
16
|
-
|
17
|
-
this.isPlaying = true;
|
18
|
-
};
|
19
|
-
|
20
|
-
Player.prototype.makeFavorite = function() {
|
21
|
-
this.currentlyPlayingSong.persistFavoriteStatus(true);
|
22
|
-
};
|
@@ -1,58 +0,0 @@
|
|
1
|
-
describe("Player", function() {
|
2
|
-
var player;
|
3
|
-
var song;
|
4
|
-
|
5
|
-
beforeEach(function() {
|
6
|
-
player = new Player();
|
7
|
-
song = new Song();
|
8
|
-
});
|
9
|
-
|
10
|
-
it("should be able to play a Song", function() {
|
11
|
-
player.play(song);
|
12
|
-
expect(player.currentlyPlayingSong).toEqual(song);
|
13
|
-
|
14
|
-
//demonstrates use of custom matcher
|
15
|
-
expect(player).toBePlaying(song);
|
16
|
-
});
|
17
|
-
|
18
|
-
describe("when song has been paused", function() {
|
19
|
-
beforeEach(function() {
|
20
|
-
player.play(song);
|
21
|
-
player.pause();
|
22
|
-
});
|
23
|
-
|
24
|
-
it("should indicate that the song is currently paused", function() {
|
25
|
-
expect(player.isPlaying).toBeFalsy();
|
26
|
-
|
27
|
-
// demonstrates use of 'not' with a custom matcher
|
28
|
-
expect(player).not.toBePlaying(song);
|
29
|
-
});
|
30
|
-
|
31
|
-
it("should be possible to resume", function() {
|
32
|
-
player.resume();
|
33
|
-
expect(player.isPlaying).toBeTruthy();
|
34
|
-
expect(player.currentlyPlayingSong).toEqual(song);
|
35
|
-
});
|
36
|
-
});
|
37
|
-
|
38
|
-
// demonstrates use of spies to intercept and test method calls
|
39
|
-
it("tells the current song if the user has made it a favorite", function() {
|
40
|
-
spyOn(song, 'persistFavoriteStatus');
|
41
|
-
|
42
|
-
player.play(song);
|
43
|
-
player.makeFavorite();
|
44
|
-
|
45
|
-
expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
|
46
|
-
});
|
47
|
-
|
48
|
-
//demonstrates use of expected exceptions
|
49
|
-
describe("#resume", function() {
|
50
|
-
it("should throw an exception if song is already playing", function() {
|
51
|
-
player.play(song);
|
52
|
-
|
53
|
-
expect(function() {
|
54
|
-
player.resume();
|
55
|
-
}).toThrow("song is already playing");
|
56
|
-
});
|
57
|
-
});
|
58
|
-
});
|