cukerail 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Guardfile +11 -0
- data/lib/cukerail/testrail.rb +108 -0
- data/lib/cukerail/version.rb +1 -1
- data/spec/cukerail_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79c5e89f98cbd32a30a5c8c31cb53b4fa08c0232
|
4
|
+
data.tar.gz: 13482906ac92bab39a3dc309353e5ffbcccc72b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a89a120497a7f817c2eb70b64d7b8cbbf4551607eb6f645efa1d7600304067d8f76ea0e17e1b4774e40d5f772aace217b4914b05475d071ab8a2c2a8d950e05
|
7
|
+
data.tar.gz: b5693a081caef579eb4268a6400e09bd1d65a30480f6aafaf93b6057ba2956645a52aa8365e68f3cb770bef9abdd0a7830e13f4e545c2a2776428e4d00fc1b79
|
data/Guardfile
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#
|
2
|
+
# TestRail API binding for Ruby (API v2, available since TestRail 3.0)
|
3
|
+
#
|
4
|
+
# Learn more:
|
5
|
+
#
|
6
|
+
# http://docs.gurock.com/testrail-api2/start
|
7
|
+
# http://docs.gurock.com/testrail-api2/accessing
|
8
|
+
#
|
9
|
+
# Copyright Gurock Software GmbH
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'net/http'
|
13
|
+
require 'net/https'
|
14
|
+
require 'uri'
|
15
|
+
require 'json'
|
16
|
+
|
17
|
+
module TestRail
|
18
|
+
class APIClient
|
19
|
+
@url = ''
|
20
|
+
@user = ''
|
21
|
+
@password = ''
|
22
|
+
|
23
|
+
attr_accessor :user
|
24
|
+
attr_accessor :password
|
25
|
+
|
26
|
+
def initialize(base_url,user,password)
|
27
|
+
if !base_url.match(/\/$/)
|
28
|
+
base_url += '/'
|
29
|
+
end
|
30
|
+
@url = base_url + 'index.php?/api/v2/'
|
31
|
+
@user ||=user
|
32
|
+
@password ||=password
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Send Get
|
37
|
+
#
|
38
|
+
# Issues a GET request (read) against the API and returns the result
|
39
|
+
# (as Ruby hash).
|
40
|
+
#
|
41
|
+
# Arguments:
|
42
|
+
#
|
43
|
+
# uri The API method to call including parameters
|
44
|
+
# (e.g. get_case/1)
|
45
|
+
#
|
46
|
+
def send_get(uri)
|
47
|
+
_send_request('GET', uri, nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Send POST
|
52
|
+
#
|
53
|
+
# Issues a POST request (write) against the API and returns the result
|
54
|
+
# (as Ruby hash).
|
55
|
+
#
|
56
|
+
# Arguments:
|
57
|
+
#
|
58
|
+
# uri The API method to call including parameters
|
59
|
+
# (e.g. add_case/1)
|
60
|
+
# data The data to submit as part of the request (as
|
61
|
+
# Ruby hash, strings must be UTF-8 encoded)
|
62
|
+
#
|
63
|
+
def send_post(uri, data)
|
64
|
+
_send_request('POST', uri, data)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
def _send_request(method, uri, data)
|
69
|
+
url = URI.parse(@url + uri)
|
70
|
+
if method == 'POST'
|
71
|
+
request = Net::HTTP::Post.new(url.path + '?' + url.query)
|
72
|
+
request.body = JSON.dump(data)
|
73
|
+
else
|
74
|
+
request = Net::HTTP::Get.new(url.path + '?' + url.query)
|
75
|
+
end
|
76
|
+
request.basic_auth(@user, @password)
|
77
|
+
request.add_field('Content-Type', 'application/json')
|
78
|
+
|
79
|
+
conn = Net::HTTP.new(url.host, url.port)
|
80
|
+
if url.scheme == 'https'
|
81
|
+
conn.use_ssl = true
|
82
|
+
conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
83
|
+
end
|
84
|
+
response = conn.request(request)
|
85
|
+
|
86
|
+
if response.body && !response.body.empty?
|
87
|
+
result = JSON.parse(response.body)
|
88
|
+
else
|
89
|
+
result = {}
|
90
|
+
end
|
91
|
+
|
92
|
+
if response.code != '200'
|
93
|
+
if result && result.key?('error')
|
94
|
+
error = '"' + result['error'] + '"'
|
95
|
+
else
|
96
|
+
error = 'No additional error message received'
|
97
|
+
end
|
98
|
+
raise APIError.new('TestRail API returned HTTP %s (%s)' %
|
99
|
+
[response.code, error])
|
100
|
+
end
|
101
|
+
|
102
|
+
result
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class APIError < StandardError
|
107
|
+
end
|
108
|
+
end
|
data/lib/cukerail/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cukerail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Small
|
@@ -90,12 +90,16 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
92
|
- Gemfile
|
93
|
+
- Guardfile
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|
95
96
|
- Rakefile
|
96
97
|
- cukerail.gemspec
|
97
98
|
- lib/cukerail.rb
|
99
|
+
- lib/cukerail/testrail.rb
|
98
100
|
- lib/cukerail/version.rb
|
101
|
+
- spec/cukerail_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
99
103
|
homepage: ''
|
100
104
|
licenses:
|
101
105
|
- MIT
|
@@ -120,4 +124,6 @@ rubygems_version: 2.2.2
|
|
120
124
|
signing_key:
|
121
125
|
specification_version: 4
|
122
126
|
summary: Integrates Cucumber and Testrail from Gurock Software
|
123
|
-
test_files:
|
127
|
+
test_files:
|
128
|
+
- spec/cukerail_spec.rb
|
129
|
+
- spec/spec_helper.rb
|