testingbot 0.1.7 → 0.2.0
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.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aa6c0651947729f8124cb6b37c2c2d06a1fc623
|
4
|
+
data.tar.gz: c70cbfddb932e5cb39f19e186c63efd468e945ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44e00e76b7afb646894a7dda5c70fbc33c5dec05a25dc9a638969cb87a70e2971571c35777fd737c24ddd98126ada1d9fb507b53cfd9b9462c0cb630298595ac
|
7
|
+
data.tar.gz: 8a774bbca0819f5af90fcc5a640361f84272638f73cdc3e848f614899d5eb7b59072c0a54585899fb18ca8a0634b3152e575ae49b195ee7ae3104dd4a17e7b09
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
[](https://travis-ci.org/testingbot/testingbot_ruby)
|
2
|
+
|
3
|
+
# Testingbot-Ruby
|
4
|
+
|
5
|
+
This is the TestingBot Ruby client which makes it easy to
|
6
|
+
interact with the [TestingBot API](https://testingbot.com/support/api)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'testingbot'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install testingbot
|
21
|
+
|
22
|
+
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
You'll need a [TestingBot account](https://testingbot.com). TestingBot offers free trials.
|
26
|
+
|
27
|
+
## Setup
|
28
|
+
|
29
|
+
Once you have a TestingBot account, you can retrieve your unique TestingBot Key and Secret from the [TestingBot dashboard](https://testingbot.com/members)
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
@api = TestingBot::Api.new(key, secret)
|
35
|
+
```
|
36
|
+
|
37
|
+
#### Environment variables
|
38
|
+
You can set these environment variables to authenticate with our API:
|
39
|
+
|
40
|
+
```bash
|
41
|
+
TB_KEY=Your TestingBot Key
|
42
|
+
TB_SECRET=Your TestingBot Secret
|
43
|
+
```
|
44
|
+
|
45
|
+
### get_browsers
|
46
|
+
Gets a list of browsers you can test on
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
@api.get_browsers
|
50
|
+
```
|
51
|
+
|
52
|
+
### get_user_info
|
53
|
+
Gets your user information
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
@api.get_user_info
|
57
|
+
```
|
58
|
+
|
59
|
+
### update_user_info
|
60
|
+
Updates your user information
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
@api.update_user_info({ "first_name" => 'my name' })
|
64
|
+
```
|
65
|
+
|
66
|
+
### update_test
|
67
|
+
Updates a Test with Meta-data to display on TestingBot.
|
68
|
+
For example, you can specify the test name and whether the test succeeded or failed:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
@api.update_test(webdriver_session_id, { :name => new_name, :success => true })
|
72
|
+
```
|
73
|
+
|
74
|
+
### get_test
|
75
|
+
Gets meta information for a test/job by passing in the WebDriver sessionID of the test you ran on TestingBot:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
@api.get_test(webdriver_session_id)
|
79
|
+
```
|
80
|
+
|
81
|
+
### get_tests
|
82
|
+
Gets a list of previous jobs/tests that you ran on TestingBot, order by last run:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
@api.get_tests(0, 10)
|
86
|
+
```
|
87
|
+
|
88
|
+
### delete_test
|
89
|
+
Deletes a test from TestingBot
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
@api.delete_test(webdriver_session_id)
|
93
|
+
```
|
94
|
+
|
95
|
+
### stop_test
|
96
|
+
Stops a running test on TestingBot
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
@api.stop_test(webdriver_session_id)
|
100
|
+
```
|
101
|
+
|
102
|
+
### get_builds
|
103
|
+
Gets a list of builds that you ran on TestingBot, order by last run:
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
@api.get_builds(0, 10)
|
107
|
+
```
|
108
|
+
|
109
|
+
### get_build
|
110
|
+
Gets a build from TestingBot
|
111
|
+
|
112
|
+
```ruby
|
113
|
+
@api.get_build(build_identifier)
|
114
|
+
```
|
115
|
+
|
116
|
+
### get_tunnels
|
117
|
+
Gets a list of active tunnels for your account.
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
@api.get_tunnels
|
121
|
+
```
|
122
|
+
|
123
|
+
### get_authentication_hash
|
124
|
+
Calculates the hash necessary to share tests with other people
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
@api.get_authentication_hash(identifier)
|
128
|
+
```
|
129
|
+
|
130
|
+
## Contributing
|
131
|
+
|
132
|
+
1. Fork this repository
|
133
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
134
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
135
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
136
|
+
5. Create new Pull Request
|
137
|
+
|
data/bin/testingbot
CHANGED
@@ -4,8 +4,9 @@ if ARGV.any?
|
|
4
4
|
api_key, api_secret = ARGV.first.split(':')
|
5
5
|
else
|
6
6
|
|
7
|
-
p "This utility will help you set up your system to use
|
8
|
-
p "Once you have entered your
|
7
|
+
p "This utility will help you set up your system to use TestingBot's infrastructure."
|
8
|
+
p "Once you have entered your API key and secret you will be ready to use our grid"
|
9
|
+
p "You can get these credentials from the TestingBot dashboard: https://testingbot.com/members"
|
9
10
|
|
10
11
|
p "Please enter your testingbot API KEY:"
|
11
12
|
api_key = gets.chomp
|
@@ -15,4 +16,4 @@ end
|
|
15
16
|
|
16
17
|
File.open(File.expand_path("~/.testingbot"), 'w') {|f| f.write("#{api_key}:#{api_secret}") }
|
17
18
|
|
18
|
-
p "Your system is now ready to use
|
19
|
+
p "Your system is now ready to use TestingBot's grid infrastructure."
|
data/lib/testingbot.rb
CHANGED
data/lib/testingbot/api.rb
CHANGED
@@ -6,16 +6,36 @@ module TestingBot
|
|
6
6
|
VERSION = 1
|
7
7
|
API_URL = "https://api.testingbot.com"
|
8
8
|
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :key, :secret, :options
|
10
|
+
|
11
|
+
def initialize(key = nil, secret = nil, options = {})
|
12
|
+
@key = key
|
13
|
+
@secret = secret
|
14
|
+
@options = {
|
15
|
+
:debug => false
|
16
|
+
}.merge(options)
|
17
|
+
if @key.nil? || @secret.nil?
|
18
|
+
cached_credentials = load_config_file
|
19
|
+
@key, @secret = cached_credentials unless cached_credentials.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
if @key.nil? || @secret.nil?
|
23
|
+
@key = ENV["TB_KEY"] if ENV["TB_KEY"]
|
24
|
+
@secret = ENV["TB_SECRET"] if ENV["TB_SECRET"]
|
25
|
+
end
|
10
26
|
|
11
|
-
|
12
|
-
|
27
|
+
raise "Please supply a TestingBot Key" if @key.nil?
|
28
|
+
raise "Please supply a TestingBot Secret" if @secret.nil?
|
13
29
|
end
|
14
30
|
|
15
31
|
def get_user_info
|
16
32
|
get("/user")
|
17
33
|
end
|
18
34
|
|
35
|
+
def get_browsers
|
36
|
+
get("/browsers")
|
37
|
+
end
|
38
|
+
|
19
39
|
def update_user_info(params = {})
|
20
40
|
new_params = {}
|
21
41
|
params.keys.each do |key|
|
@@ -29,7 +49,7 @@ module TestingBot
|
|
29
49
|
get("/tests?offset=#{offset}&count=#{count}")
|
30
50
|
end
|
31
51
|
|
32
|
-
def
|
52
|
+
def get_test(test_id)
|
33
53
|
get("/tests/#{test_id}")
|
34
54
|
end
|
35
55
|
|
@@ -47,38 +67,83 @@ module TestingBot
|
|
47
67
|
response["success"]
|
48
68
|
end
|
49
69
|
|
70
|
+
def stop_test(test_id)
|
71
|
+
response = put("/tests/#{test_id}/stop")
|
72
|
+
response["success"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def get_builds(offset = 0, count = 10)
|
76
|
+
get("/builds?offset=#{offset}&count=#{count}")
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_build(build_identifier)
|
80
|
+
get("/builds/#{build_identifier}")
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_tunnels
|
84
|
+
get("/tunnel/list")
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_authentication_hash(identifier)
|
88
|
+
Digest::MD5.hexdigest("#{@key}:#{@secret}:#{identifier}")
|
89
|
+
end
|
90
|
+
|
50
91
|
private
|
51
92
|
|
93
|
+
def load_config_file
|
94
|
+
is_windows = false
|
95
|
+
|
96
|
+
begin
|
97
|
+
require 'rbconfig'
|
98
|
+
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
|
99
|
+
rescue
|
100
|
+
is_windows = (RUBY_PLATFORM =~ /w.*32/) || (ENV["OS"] && ENV["OS"] == "Windows_NT")
|
101
|
+
end
|
102
|
+
|
103
|
+
if is_windows
|
104
|
+
config_file = "#{ENV['HOMEDRIVE']}\\.testingbot"
|
105
|
+
else
|
106
|
+
config_file = File.expand_path("#{Dir.home}/.testingbot")
|
107
|
+
end
|
108
|
+
|
109
|
+
if File.exists?(config_file)
|
110
|
+
str = File.open(config_file) { |f| f.readline }.chomp
|
111
|
+
return str.split(':')
|
112
|
+
end
|
113
|
+
|
114
|
+
return nil
|
115
|
+
end
|
116
|
+
|
52
117
|
def get(url)
|
53
118
|
uri = URI(API_URL + '/v' + VERSION.to_s + url)
|
54
119
|
req = Net::HTTP::Get.new(uri.request_uri)
|
55
|
-
req.basic_auth @
|
120
|
+
req.basic_auth @key, @secret
|
56
121
|
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) {|http|
|
57
122
|
http.request(req)
|
58
123
|
}
|
59
|
-
p res.body
|
60
124
|
|
61
125
|
parsed = JSON.parse(res.body)
|
62
|
-
|
63
|
-
|
126
|
+
p parsed if @options[:debug]
|
127
|
+
|
128
|
+
if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
|
64
129
|
raise parsed["error"]
|
65
130
|
end
|
66
|
-
|
67
131
|
parsed
|
68
132
|
end
|
69
133
|
|
70
134
|
def put(url, params = {})
|
71
135
|
uri = URI(API_URL + '/v' + VERSION.to_s + url)
|
72
136
|
req = Net::HTTP::Put.new(uri.request_uri)
|
73
|
-
req.basic_auth @
|
137
|
+
req.basic_auth @key, @secret
|
74
138
|
req.set_form_data(params)
|
75
139
|
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) {|http|
|
76
140
|
http.request(req)
|
77
141
|
}
|
78
142
|
|
79
143
|
parsed = JSON.parse(res.body)
|
144
|
+
p parsed if @options[:debug]
|
80
145
|
|
81
|
-
if !parsed["error"].nil? && !parsed["error"].empty?
|
146
|
+
if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
|
82
147
|
raise parsed["error"]
|
83
148
|
end
|
84
149
|
|
@@ -88,7 +153,7 @@ module TestingBot
|
|
88
153
|
def delete(url, params = {})
|
89
154
|
uri = URI(API_URL + '/v' + VERSION.to_s + url)
|
90
155
|
req = Net::HTTP::Delete.new(uri.request_uri)
|
91
|
-
req.basic_auth @
|
156
|
+
req.basic_auth @key, @secret
|
92
157
|
req.set_form_data(params)
|
93
158
|
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) {|http|
|
94
159
|
http.request(req)
|
@@ -96,7 +161,9 @@ module TestingBot
|
|
96
161
|
|
97
162
|
parsed = JSON.parse(res.body)
|
98
163
|
|
99
|
-
|
164
|
+
p parsed if @options[:debug]
|
165
|
+
|
166
|
+
if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
|
100
167
|
raise parsed["error"]
|
101
168
|
end
|
102
169
|
|
@@ -107,8 +174,17 @@ module TestingBot
|
|
107
174
|
url = URI.parse(API_URL + '/v' + VERSION + url)
|
108
175
|
http = Net::HTTP.new(url.host, url.port)
|
109
176
|
http.use_ssl = true
|
110
|
-
http.basic_auth @
|
111
|
-
|
177
|
+
http.basic_auth @key, @secret
|
178
|
+
res = http.post(url.path, params.map { |k, v| "#{k.to_s}=#{v}" }.join("&"))
|
179
|
+
parsed = JSON.parse(res.body)
|
180
|
+
|
181
|
+
p parsed if @options[:debug]
|
182
|
+
|
183
|
+
if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
|
184
|
+
raise parsed["error"]
|
185
|
+
end
|
186
|
+
|
187
|
+
parsed
|
112
188
|
end
|
113
189
|
end
|
114
190
|
end
|
data/lib/testingbot/version.rb
CHANGED
@@ -4,23 +4,22 @@ require 'rspec'
|
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
5
5
|
|
6
6
|
describe "Testingbot Api" do
|
7
|
-
|
8
7
|
context "the API should return valid user information" do
|
9
8
|
it "should return info for the current user" do
|
10
|
-
@api = TestingBot::Api.new
|
9
|
+
@api = TestingBot::Api.new
|
11
10
|
@api.get_user_info.should_not be_empty
|
12
11
|
@api.get_user_info["first_name"].should_not be_empty
|
13
12
|
end
|
14
13
|
|
15
14
|
it "should raise an error when wrong credentials are provided" do
|
16
|
-
@api = TestingBot::Api.new(
|
15
|
+
@api = TestingBot::Api.new("bogus", "false")
|
17
16
|
lambda { @api.get_user_info }.should raise_error(RuntimeError, /^401 Unauthorized/)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
context "updating my user info via the API should work" do
|
22
21
|
it "should allow me to update my own user info" do
|
23
|
-
@api = TestingBot::Api.new
|
22
|
+
@api = TestingBot::Api.new
|
24
23
|
new_name = rand(36**9).to_s(36)
|
25
24
|
@api.update_user_info({ "first_name" => new_name }).should == true
|
26
25
|
@api.get_user_info["first_name"].should == new_name
|
@@ -29,59 +28,66 @@ describe "Testingbot Api" do
|
|
29
28
|
|
30
29
|
context "retrieve my own tests" do
|
31
30
|
it "should retrieve a list of my own tests" do
|
32
|
-
@api = TestingBot::Api.new
|
31
|
+
@api = TestingBot::Api.new
|
33
32
|
@api.get_tests.include?("data").should == true
|
34
33
|
end
|
35
34
|
|
36
35
|
it "should provide info for a specific test" do
|
37
|
-
@api = TestingBot::Api.new
|
36
|
+
@api = TestingBot::Api.new
|
38
37
|
data = @api.get_tests["data"]
|
39
38
|
if data.length > 0
|
40
39
|
test_id = data.first["id"]
|
41
40
|
|
42
|
-
single_test = @api.
|
41
|
+
single_test = @api.get_test(test_id)
|
43
42
|
single_test["id"].should == test_id
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
46
|
it "should fail when trying to access a test that is not mine" do
|
48
|
-
@api = TestingBot::Api.new
|
49
|
-
lambda { @api.
|
47
|
+
@api = TestingBot::Api.new
|
48
|
+
lambda { @api.get_test(123423423423423) }.should raise_error(RuntimeError, /^404 Not Found./)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
context "update a test" do
|
54
53
|
it "should update a test of mine" do
|
55
|
-
@api = TestingBot::Api.new
|
54
|
+
@api = TestingBot::Api.new
|
56
55
|
data = @api.get_tests["data"]
|
57
56
|
if data.length > 0
|
58
57
|
test_id = data.first["id"]
|
59
58
|
new_name = rand(36**9).to_s(36)
|
60
59
|
@api.update_test(test_id, { :name => new_name }).should == true
|
61
|
-
single_test = @api.
|
60
|
+
single_test = @api.get_test(test_id)
|
62
61
|
single_test["name"].should == new_name
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
it "should not update a test that is not mine" do
|
67
|
-
@api = TestingBot::Api.new
|
66
|
+
@api = TestingBot::Api.new
|
68
67
|
lambda { @api.update_test(123423423423423, { :name => "testingbot" }) }.should raise_error(RuntimeError, /^404 Not Found./)
|
69
68
|
end
|
70
69
|
end
|
71
70
|
|
71
|
+
context "fetch browsers" do
|
72
|
+
it "should fetch a list of browsers" do
|
73
|
+
@api = TestingBot::Api.new
|
74
|
+
@api.get_browsers.should_not be_empty
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
72
78
|
context "delete a test" do
|
73
79
|
it "should delete a test of mine" do
|
74
|
-
@api = TestingBot::Api.new
|
80
|
+
@api = TestingBot::Api.new
|
75
81
|
data = @api.get_tests["data"]
|
76
82
|
if data.length > 0
|
77
83
|
test_id = data.first["id"]
|
78
84
|
@api.delete_test(test_id).should == true
|
79
|
-
lambda { @api.
|
85
|
+
lambda { @api.get_test(test_id) }.should raise_error(RuntimeError, /^404 Not Found./)
|
80
86
|
end
|
81
87
|
end
|
82
88
|
|
83
89
|
it "should not delete a test that is not mine" do
|
84
|
-
@api = TestingBot::Api.new
|
90
|
+
@api = TestingBot::Api.new
|
85
91
|
lambda { @api.delete_test(123423423423423) }.should raise_error(RuntimeError, /^404 Not Found./)
|
86
92
|
end
|
87
93
|
end
|