cukerail 0.5.0 → 0.5.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.
- checksums.yaml +4 -4
- data/cukerail.gemspec +1 -0
- data/lib/cukerail/testrail.rb +84 -82
- data/lib/cukerail/version.rb +1 -1
- data/lib/tasks/cukerail.rake +5 -5
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcf11c201ebb1d8a3983d0bf8f80ea5601a8f8d1
|
4
|
+
data.tar.gz: 449e790155052adc1014ecd84fc9ebcffbef8ab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0422b5e13cb506b90f6caaad39065a215fb5139c69c06029de08df2fa68084f9ddb918ee0a6430a03023d5a79760a8e32fc37fffdfabb089d770e87a62bc3464
|
7
|
+
data.tar.gz: 2867d379b4c42b7bd9640fec0cfc4b70cd9a2f6025a8a33da541d10e6207a5d62c6efa1327b5fd582c43bb5a92284223ee00eb1ce8558976197afb023cc78eb5
|
data/cukerail.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_runtime_dependency "cucumber", "~> 2.3.2"
|
24
|
+
spec.add_runtime_dependency 'retriable', '~> 2.1'
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
26
27
|
spec.add_development_dependency "rake","~>10.4"
|
data/lib/cukerail/testrail.rb
CHANGED
@@ -13,99 +13,101 @@ require 'net/http'
|
|
13
13
|
require 'net/https'
|
14
14
|
require 'uri'
|
15
15
|
require 'json'
|
16
|
-
|
16
|
+
require 'retriable'
|
17
17
|
module TestRail
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
class APIClient
|
19
|
+
@url = ''
|
20
|
+
@user = ''
|
21
|
+
@password = ''
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
attr_accessor :user
|
24
|
+
attr_accessor :password
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
def initialize(base_url,user,password,proxy_url=nil,proxy_port=nil)
|
27
|
+
if !base_url.match(/\/$/)
|
28
|
+
base_url += '/'
|
29
|
+
end
|
30
|
+
@url = base_url + 'index.php?/api/v2/'
|
31
31
|
@user ||=user
|
32
32
|
@password ||=password
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
@proxy_url ||= proxy_url
|
34
|
+
@proxy_port ||= proxy_port
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Send Get
|
39
|
+
#
|
40
|
+
# Issues a GET request (read) against the API and returns the result
|
41
|
+
# (as Ruby hash).
|
42
|
+
#
|
43
|
+
# Arguments:
|
44
|
+
#
|
45
|
+
# uri The API method to call including parameters
|
46
|
+
# (e.g. get_case/1)
|
47
|
+
#
|
48
|
+
def send_get(uri)
|
49
|
+
_send_request('GET', uri, nil)
|
50
|
+
end
|
36
51
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
#
|
53
|
+
# Send POST
|
54
|
+
#
|
55
|
+
# Issues a POST request (write) against the API and returns the result
|
56
|
+
# (as Ruby hash).
|
57
|
+
#
|
58
|
+
# Arguments:
|
59
|
+
#
|
60
|
+
# uri The API method to call including parameters
|
61
|
+
# (e.g. add_case/1)
|
62
|
+
# data The data to submit as part of the request (as
|
63
|
+
# Ruby hash, strings must be UTF-8 encoded)
|
64
|
+
#
|
65
|
+
def send_post(uri, data)
|
66
|
+
_send_request('POST', uri, data)
|
67
|
+
end
|
51
68
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
#
|
65
|
-
def send_post(uri, data)
|
66
|
-
_send_request('POST', uri, data)
|
67
|
-
end
|
69
|
+
private
|
70
|
+
def _send_request(method, uri, data)
|
71
|
+
Retriable.retriable multiplier: 3 do
|
72
|
+
url = URI.parse(@url + uri)
|
73
|
+
if method == 'POST'
|
74
|
+
request = Net::HTTP::Post.new(url.path + '?' + url.query)
|
75
|
+
request.body = JSON.dump(data)
|
76
|
+
else
|
77
|
+
request = Net::HTTP::Get.new(url.path + '?' + url.query)
|
78
|
+
end
|
79
|
+
request.basic_auth(@user, @password)
|
80
|
+
request.add_field('Content-Type', 'application/json')
|
68
81
|
|
69
|
-
|
70
|
-
def _send_request(method, uri, data)
|
71
|
-
url = URI.parse(@url + uri)
|
72
|
-
if method == 'POST'
|
73
|
-
request = Net::HTTP::Post.new(url.path + '?' + url.query)
|
74
|
-
request.body = JSON.dump(data)
|
75
|
-
else
|
76
|
-
request = Net::HTTP::Get.new(url.path + '?' + url.query)
|
77
|
-
end
|
78
|
-
request.basic_auth(@user, @password)
|
79
|
-
request.add_field('Content-Type', 'application/json')
|
82
|
+
conn = Net::HTTP.new(url.host, url.port,@proxy_url,@proxy_port)
|
80
83
|
|
81
|
-
|
84
|
+
if url.scheme == 'https'
|
85
|
+
conn.use_ssl = true
|
86
|
+
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
87
|
+
end
|
88
|
+
response = conn.request(request)
|
82
89
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
90
|
+
if response.body && !response.body.empty?
|
91
|
+
result = JSON.parse(response.body)
|
92
|
+
else
|
93
|
+
result = {}
|
94
|
+
end
|
88
95
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
96
|
+
if response.code != '200'
|
97
|
+
if result && result.key?('error')
|
98
|
+
error = '"' + result['error'] + '"'
|
99
|
+
else
|
100
|
+
error = 'No additional error message received'
|
101
|
+
end
|
102
|
+
raise APIError.new('TestRail API returned HTTP %s (%s)' %
|
103
|
+
[response.code, error])
|
104
|
+
end
|
94
105
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
error = 'No additional error message received'
|
100
|
-
end
|
101
|
-
raise APIError.new('TestRail API returned HTTP %s (%s)' %
|
102
|
-
[response.code, error])
|
103
|
-
end
|
104
|
-
|
105
|
-
result
|
106
|
-
end
|
107
|
-
end
|
106
|
+
result
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
108
110
|
|
109
|
-
|
110
|
-
|
111
|
+
class APIError < StandardError
|
112
|
+
end
|
111
113
|
end
|
data/lib/cukerail/version.rb
CHANGED
data/lib/tasks/cukerail.rake
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative '../json_sender'
|
2
|
-
desc 'load a json results file into a test suite'
|
2
|
+
desc 'load a json results file into a test suite, JSON=filename'
|
3
3
|
task :load_to_suite do
|
4
4
|
raise 'You must have JSON=filename on the command line' unless ENV['JSON']
|
5
5
|
json_sender =Cukerail::JsonSender.new(ENV['JSON'])
|
@@ -20,7 +20,7 @@ task :load_to_suite do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
desc 'load a json results file into a test run'
|
23
|
+
desc 'load a json results file into a test run TESTRUN=run_number JSON=filename'
|
24
24
|
task :load_to_test_run do
|
25
25
|
raise 'You must have TESTRUN=testrun_number on the command line' unless ENV['TESTRUN']
|
26
26
|
json_sender =Cukerail::JsonSender.new(ENV['JSON'])
|
@@ -35,7 +35,7 @@ task :load_to_test_run do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
desc "remove cases from a test run that are aren't in the json results"
|
38
|
+
desc "remove cases from a test run that are aren't in the json results, TESTRUN=run_number JSON=filename"
|
39
39
|
task :remove_from_test_run do
|
40
40
|
raise 'You must have TESTRUN=testrun_number on the command line' unless ENV['TESTRUN']
|
41
41
|
raise 'You must have JSON=filename on the command line' unless ENV['JSON']
|
@@ -49,11 +49,11 @@ task :remove_from_test_run do
|
|
49
49
|
json_sender.remove_all_except_these_cases_from_testrun(testcase_ids,ENV['TESTRUN'].to_i)
|
50
50
|
end
|
51
51
|
|
52
|
-
desc "match test run cases to json results file"
|
52
|
+
desc "match test run cases to json results file,"
|
53
53
|
task match_to_test_run: [:remove_from_test_run,:load_to_test_run] do
|
54
54
|
end
|
55
55
|
|
56
|
-
desc "remove cases from a test suite that aren't in the json results"
|
56
|
+
desc "remove cases from a test suite that aren't in the json results, TESTRUN=run_number JSON=filename"
|
57
57
|
task :remove_from_test_suite do
|
58
58
|
raise 'You must have JSON=filename on the command line' unless ENV['JSON']
|
59
59
|
json_sender =Cukerail::JsonSender.new(ENV['JSON'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cukerail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Small
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.3.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: retriable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|