testingbot 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8aa6c0651947729f8124cb6b37c2c2d06a1fc623
4
- data.tar.gz: c70cbfddb932e5cb39f19e186c63efd468e945ec
2
+ SHA256:
3
+ metadata.gz: 794e0199499d4673ec0942705d9de3ac37b5535211127dc1e3a291d63ea4cd03
4
+ data.tar.gz: 1f2566eb58ec86366945312443c855d40d0995a24bbf848e8c7142919a596040
5
5
  SHA512:
6
- metadata.gz: 44e00e76b7afb646894a7dda5c70fbc33c5dec05a25dc9a638969cb87a70e2971571c35777fd737c24ddd98126ada1d9fb507b53cfd9b9462c0cb630298595ac
7
- data.tar.gz: 8a774bbca0819f5af90fcc5a640361f84272638f73cdc3e848f614899d5eb7b59072c0a54585899fb18ca8a0634b3152e575ae49b195ee7ae3104dd4a17e7b09
6
+ metadata.gz: 03d64dfda0351d513576dbb4c01645d75863ddac7f05c2f25530b8e736b78db4d02f9e35e2c18e6db67def006af387d849efd83968d36ba99a4b7e245c550179
7
+ data.tar.gz: def50ac030356038be8f378ae29e4fd7d51120f5d9d18b5ad8d571d23bed0cd0f2b064228c6cd2e5bfd4e548291d45e29c4ee7e124a34054177c6024be886999
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
4
  - 2.1.1
6
- script: bundle exec rake spec
5
+ - 2.3
6
+ - 2.4
7
+ - 2.5
8
+ - 2.6
9
+ script: bundle exec rake spec
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/testingbot/testingbot_ruby.png)](https://travis-ci.org/testingbot/testingbot_ruby)
2
+ [![Gem Version](https://badge.fury.io/rb/testingbot.svg)](https://badge.fury.io/rb/testingbot)
2
3
 
3
4
  # Testingbot-Ruby
4
5
 
@@ -120,6 +121,40 @@ Gets a list of active tunnels for your account.
120
121
  @api.get_tunnels
121
122
  ```
122
123
 
124
+ ### upload_local_file
125
+ Uploads a local file (APK or IPA file) to TestingBot Storage for Mobile App Testing.
126
+
127
+ ```ruby
128
+ @api.upload_local_file(localFilePath)
129
+ ```
130
+
131
+ ### upload_remote_file
132
+ Uploads a remote file (APK or IPA URL) to TestingBot Storage for Mobile App Testing.
133
+
134
+ ```ruby
135
+ @api.upload_remote_file(remoteFileUrl)
136
+ ```
137
+
138
+ ### get_uploaded_files
139
+ Retrieves files previously uploaded TestingBot Storage for Mobile App Testing.
140
+
141
+ ```ruby
142
+ @api.get_uploaded_files(offset = 0, count = 30)
143
+ ```
144
+
145
+ ### get_uploaded_file
146
+ Retrieves meta-data for a file previously uploaded to TestingBot Storage.
147
+
148
+ ```ruby
149
+ @api.get_uploaded_file(app_url)
150
+ ```
151
+
152
+ ### upload_remote_file
153
+ Uploads a remote file (APK or IPA URL) to TestingBot Storage for Mobile App Testing.
154
+
155
+ ```ruby
156
+ @api.upload_remote_file(remoteFileUrl)
157
+ ```
123
158
  ### get_authentication_hash
124
159
  Calculates the hash necessary to share tests with other people
125
160
 
@@ -1,4 +1,6 @@
1
1
  require 'json'
2
+ require "rest-client"
3
+
2
4
  module TestingBot
3
5
 
4
6
  class Api
@@ -19,6 +21,11 @@ module TestingBot
19
21
  @key, @secret = cached_credentials unless cached_credentials.nil?
20
22
  end
21
23
 
24
+ if @key.nil? || @secret.nil?
25
+ @key = ENV["TESTINGBOT_KEY"] if ENV["TESTINGBOT_KEY"]
26
+ @secret = ENV["TESTINGBOT_SECRET"] if ENV["TESTINGBOT_SECRET"]
27
+ end
28
+
22
29
  if @key.nil? || @secret.nil?
23
30
  @key = ENV["TB_KEY"] if ENV["TB_KEY"]
24
31
  @secret = ENV["TB_SECRET"] if ENV["TB_SECRET"]
@@ -88,6 +95,41 @@ module TestingBot
88
95
  Digest::MD5.hexdigest("#{@key}:#{@secret}:#{identifier}")
89
96
  end
90
97
 
98
+ def upload_local_file(file_path)
99
+ response = RestClient::Request.execute(
100
+ method: :post,
101
+ url: API_URL + "/v1/storage",
102
+ user: @key,
103
+ password: @secret,
104
+ timeout: 600,
105
+ payload: {
106
+ multipart: true,
107
+ file: File.new(file_path, 'rb')
108
+ }
109
+ )
110
+ parsed = JSON.parse(response.body)
111
+ parsed
112
+ end
113
+
114
+ def upload_remote_file(url)
115
+ post("/storage/", {
116
+ :url => url
117
+ })
118
+ end
119
+
120
+ def get_uploaded_files(offset = 0, count = 10)
121
+ get("/storage?offset=#{offset}&count=#{count}")
122
+ end
123
+
124
+ def get_uploaded_file(app_url)
125
+ get("/storage/#{app_url.gsub(/tb:\/\//, '')}")
126
+ end
127
+
128
+ def delete_uploaded_file(app_url)
129
+ response = delete("/storage/#{app_url.gsub(/tb:\/\//, '')}")
130
+ response["success"]
131
+ end
132
+
91
133
  private
92
134
 
93
135
  def load_config_file
@@ -115,34 +157,26 @@ module TestingBot
115
157
  end
116
158
 
117
159
  def get(url)
118
- uri = URI(API_URL + '/v' + VERSION.to_s + url)
119
- req = Net::HTTP::Get.new(uri.request_uri)
120
- req.basic_auth @key, @secret
121
- res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) {|http|
122
- http.request(req)
123
- }
124
-
125
- parsed = JSON.parse(res.body)
160
+ uri = API_URL + '/v' + VERSION.to_s + url
161
+
162
+ response = RestClient::Request.execute method: :get, url: uri, user: @key, password: @secret
163
+ parsed = JSON.parse(response.body)
164
+
126
165
  p parsed if @options[:debug]
127
-
128
166
  if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
129
167
  raise parsed["error"]
130
168
  end
169
+
131
170
  parsed
132
171
  end
133
172
 
134
173
  def put(url, params = {})
135
- uri = URI(API_URL + '/v' + VERSION.to_s + url)
136
- req = Net::HTTP::Put.new(uri.request_uri)
137
- req.basic_auth @key, @secret
138
- req.set_form_data(params)
139
- res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) {|http|
140
- http.request(req)
141
- }
142
-
143
- parsed = JSON.parse(res.body)
144
- p parsed if @options[:debug]
174
+ uri = API_URL + '/v' + VERSION.to_s + url
145
175
 
176
+ response = RestClient::Request.execute method: :put, url: uri, payload: params, user: @key, password: @secret
177
+ parsed = JSON.parse(response.body)
178
+
179
+ p parsed if @options[:debug]
146
180
  if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
147
181
  raise parsed["error"]
148
182
  end
@@ -151,18 +185,11 @@ module TestingBot
151
185
  end
152
186
 
153
187
  def delete(url, params = {})
154
- uri = URI(API_URL + '/v' + VERSION.to_s + url)
155
- req = Net::HTTP::Delete.new(uri.request_uri)
156
- req.basic_auth @key, @secret
157
- req.set_form_data(params)
158
- res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) {|http|
159
- http.request(req)
160
- }
161
-
162
- parsed = JSON.parse(res.body)
188
+ uri = API_URL + '/v' + VERSION.to_s + url
189
+ response = RestClient::Request.execute method: :delete, url: uri, payload: params, user: @key, password: @secret
190
+ parsed = JSON.parse(response.body)
163
191
 
164
192
  p parsed if @options[:debug]
165
-
166
193
  if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
167
194
  raise parsed["error"]
168
195
  end
@@ -171,15 +198,12 @@ module TestingBot
171
198
  end
172
199
 
173
200
  def post(url, params = {})
174
- url = URI.parse(API_URL + '/v' + VERSION + url)
175
- http = Net::HTTP.new(url.host, url.port)
176
- http.use_ssl = true
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)
201
+ uri = API_URL + '/v' + VERSION.to_s + url
180
202
 
181
- p parsed if @options[:debug]
203
+ response = RestClient::Request.execute method: :post, url: uri, payload: params, user: @key, password: @secret
204
+ parsed = JSON.parse(response.body)
182
205
 
206
+ p parsed if @options[:debug]
183
207
  if !parsed.is_a?(Array) && !parsed["error"].nil? && !parsed["error"].empty?
184
208
  raise parsed["error"]
185
209
  end
@@ -1,3 +1,3 @@
1
1
  module Testingbot
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -13,7 +13,7 @@ describe "Testingbot Api" do
13
13
 
14
14
  it "should raise an error when wrong credentials are provided" do
15
15
  @api = TestingBot::Api.new("bogus", "false")
16
- lambda { @api.get_user_info }.should raise_error(RuntimeError, /^401 Unauthorized/)
16
+ lambda { @api.get_user_info }.should raise_error(RestClient::Unauthorized)
17
17
  end
18
18
  end
19
19
 
@@ -45,7 +45,7 @@ describe "Testingbot Api" do
45
45
 
46
46
  it "should fail when trying to access a test that is not mine" do
47
47
  @api = TestingBot::Api.new
48
- lambda { @api.get_test(123423423423423) }.should raise_error(RuntimeError, /^404 Not Found./)
48
+ lambda { @api.get_test(123423423423423) }.should raise_error(RestClient::NotFound)
49
49
  end
50
50
  end
51
51
 
@@ -64,7 +64,7 @@ describe "Testingbot Api" do
64
64
 
65
65
  it "should not update a test that is not mine" do
66
66
  @api = TestingBot::Api.new
67
- lambda { @api.update_test(123423423423423, { :name => "testingbot" }) }.should raise_error(RuntimeError, /^404 Not Found./)
67
+ lambda { @api.update_test(123423423423423, { :name => "testingbot" }) }.should raise_error(RestClient::NotFound)
68
68
  end
69
69
  end
70
70
 
@@ -82,13 +82,27 @@ describe "Testingbot Api" do
82
82
  if data.length > 0
83
83
  test_id = data.first["id"]
84
84
  @api.delete_test(test_id).should == true
85
- lambda { @api.get_test(test_id) }.should raise_error(RuntimeError, /^404 Not Found./)
85
+ lambda { @api.get_test(test_id) }.should raise_error(RestClient::NotFound)
86
86
  end
87
87
  end
88
88
 
89
89
  it "should not delete a test that is not mine" do
90
90
  @api = TestingBot::Api.new
91
- lambda { @api.delete_test(123423423423423) }.should raise_error(RuntimeError, /^404 Not Found./)
91
+ lambda { @api.delete_test(123423423423423) }.should raise_error(RestClient::NotFound)
92
+ end
93
+ end
94
+
95
+ context "TestingBot Storage" do
96
+ it "should upload a local file" do
97
+ @api = TestingBot::Api.new
98
+ response = @api.upload_local_file(File.join(File.dirname(__FILE__), "../resources/test.apk"))
99
+ response["app_url"].should include("tb://")
100
+ end
101
+
102
+ it "should upload a remote file" do
103
+ @api = TestingBot::Api.new
104
+ response = @api.upload_remote_file("https://testingbot.com/appium/sample.apk")
105
+ response["app_url"].should include("tb://")
92
106
  end
93
107
  end
94
108
  end
@@ -0,0 +1 @@
1
+ ok
metadata CHANGED
@@ -1,45 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testingbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jochen Delabie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2019-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: json
14
+ name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: net-http-persistent
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: selenium-webdriver
28
+ name: json
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
@@ -56,16 +42,16 @@ dependencies:
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - ">="
45
+ - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 2.9.0
47
+ version: '3.3'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - ">="
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 2.9.0
54
+ version: '3.3'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -99,10 +85,11 @@ files:
99
85
  - lib/testingbot/api.rb
100
86
  - lib/testingbot/version.rb
101
87
  - spec/integration/api_spec.rb
88
+ - spec/resources/test.apk
102
89
  - spec/spec_helper.rb
103
- - testingbot.gemspec
104
90
  homepage: https://testingbot.com
105
- licenses: []
91
+ licenses:
92
+ - MIT
106
93
  metadata: {}
107
94
  post_install_message:
108
95
  rdoc_options: []
@@ -110,9 +97,9 @@ require_paths:
110
97
  - lib
111
98
  required_ruby_version: !ruby/object:Gem::Requirement
112
99
  requirements:
113
- - - ">="
100
+ - - "~>"
114
101
  - !ruby/object:Gem::Version
115
- version: '0'
102
+ version: '2.0'
116
103
  required_rubygems_version: !ruby/object:Gem::Requirement
117
104
  requirements:
118
105
  - - ">="
@@ -120,10 +107,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
107
  version: '0'
121
108
  requirements: []
122
109
  rubyforge_project: testingbot
123
- rubygems_version: 2.6.14
110
+ rubygems_version: 2.7.8
124
111
  signing_key:
125
112
  specification_version: 4
126
113
  summary: Ruby API Gem to be used with testingbot.com
127
114
  test_files:
128
115
  - spec/integration/api_spec.rb
116
+ - spec/resources/test.apk
129
117
  - spec/spec_helper.rb
@@ -1,25 +0,0 @@
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 Delabie"]
9
- s.email = ["info@testingbot.com"]
10
- s.homepage = "https://testingbot.com"
11
- s.summary = "Ruby API Gem to be used with testingbot.com"
12
- s.description = "This gem makes interacting with the TestingBot API easy with Ruby"
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 "json"
21
- s.add_dependency "net-http-persistent"
22
- s.add_dependency "selenium-webdriver"
23
- s.add_development_dependency "rspec", [">= 2.9.0"]
24
- s.add_development_dependency "rake"
25
- end