testrail-ruby 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +3 -3
- data/lib/endpoints.rb +31 -30
- data/lib/testrail-ruby.rb +15 -19
- data/lib/testrail/deprecated/client.rb +3 -5
- data/lib/testrail/deprecated/command_helper.rb +1 -0
- data/lib/testrail/deprecated/config.rb +5 -6
- data/lib/testrail/deprecated/request.rb +2 -2
- data/lib/testrail/deprecated/response.rb +3 -2
- data/lib/version.rb +2 -2
- data/spec/spec_helper.rb +3 -3
- data/spec/testrail/ruby_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7dc968b6ee60b0fbe59877dc0c4e1d381dbcbed
|
4
|
+
data.tar.gz: 104a5671fec2a629e9a2ce442058ed4d35d0a1e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7511608a072190f6a47d2fdf1659e7271ac73235541787a5d1a0de018e946ccf705c3879b8a62047b78ce6308421e0072211971693ac31224c9833f92e492b1
|
7
|
+
data.tar.gz: 2c2baf0102af3d77b1de33c9da9f58d1cb0a4e9a39a343896824eb1a3a24b17bb2424431d28519e21ff11c1de6fdc028146b77b5581aceef2ec374405add3a16
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
43
43
|
|
44
44
|
## Contributing
|
45
45
|
|
46
|
-
Bug reports and pull requests are welcome on
|
46
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/RubyToolbox/testrail-ruby
|
47
47
|
|
48
48
|
## License
|
49
49
|
|
data/Rakefile
CHANGED
data/lib/endpoints.rb
CHANGED
@@ -4,117 +4,118 @@
|
|
4
4
|
#
|
5
5
|
module Endpoints
|
6
6
|
def add_result(test_id, opts = {})
|
7
|
-
|
7
|
+
send_post("add_result/#{test_id}", opts)
|
8
8
|
end
|
9
9
|
|
10
10
|
def add_result_for_case(run_id, case_id, opts = {})
|
11
|
-
|
11
|
+
send_post("add_result_for_case/#{run_id}/#{case_id}", opts)
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_test(test_id, opts = {})
|
15
|
-
|
15
|
+
send_get("get_test/#{test_id}", opts)
|
16
16
|
end
|
17
17
|
|
18
18
|
def get_tests(run_id, opts = {})
|
19
|
-
|
19
|
+
send_get("get_tests/#{run_id}", opts)
|
20
20
|
end
|
21
21
|
|
22
22
|
def get_case(case_id, opts = {})
|
23
|
-
|
23
|
+
send_get("get_case/#{case_id}", opts)
|
24
24
|
end
|
25
25
|
|
26
26
|
def get_cases(suite_id, section_id, opts = {})
|
27
|
-
|
27
|
+
send_get("get_cases/#{suite_id}/#{section_id}", opts)
|
28
28
|
end
|
29
29
|
|
30
30
|
def add_case(section_id, opts = {})
|
31
|
-
|
31
|
+
send_post("add_case/#{section_id}", opts)
|
32
32
|
end
|
33
33
|
|
34
34
|
def update_case(case_id, opts = {})
|
35
|
-
|
35
|
+
send_post("update_case/#{case_id}", opts)
|
36
36
|
end
|
37
37
|
|
38
38
|
def delete_case(case_id, opts = {})
|
39
|
-
|
39
|
+
send_post("delete_case/#{case_id}", opts)
|
40
40
|
end
|
41
|
+
|
41
42
|
def get_suite(suite_id, opts = {})
|
42
|
-
|
43
|
+
send_get("get_suite/#{suite_id}", opts)
|
43
44
|
end
|
44
45
|
|
45
46
|
def get_suites(project_id, opts = {})
|
46
|
-
|
47
|
+
send_get("get_suites/#{project_id}", opts)
|
47
48
|
end
|
48
49
|
|
49
50
|
def get_section(section_id, opts = {})
|
50
|
-
|
51
|
+
send_get("get_section/#{section_id}", opts)
|
51
52
|
end
|
52
53
|
|
53
54
|
def get_sections(suite_id, opts = {})
|
54
|
-
|
55
|
+
send_get("get_sections/#{suite_id}", opts)
|
55
56
|
end
|
56
57
|
|
57
58
|
def add_suite(project_id, opts = {})
|
58
|
-
|
59
|
+
send_post("add_suite/#{project_id}", opts)
|
59
60
|
end
|
60
61
|
|
61
62
|
def add_section(suite_id, opts = {})
|
62
|
-
|
63
|
+
send_post("add_section/#{suite_id}", opts)
|
63
64
|
end
|
64
65
|
|
65
66
|
def get_run(run_id, opts = {})
|
66
|
-
|
67
|
+
send_get("get_run/#{run_id}", opts)
|
67
68
|
end
|
68
69
|
|
69
70
|
def get_runs(project_id, plan_id, opts = {})
|
70
|
-
|
71
|
+
send_get("get_runs/#{project_id}/#{plan_id}", opts)
|
71
72
|
end
|
72
73
|
|
73
74
|
def add_run(suite_id, opts = {})
|
74
|
-
|
75
|
+
send_post("add_run/#{suite_id}", opts)
|
75
76
|
end
|
76
77
|
|
77
78
|
def close_run(run_id, opts = {})
|
78
|
-
|
79
|
+
send_post("close_run/#{run_id}", opts)
|
79
80
|
end
|
80
81
|
|
81
82
|
def get_plan(plan_id, opts = {})
|
82
|
-
|
83
|
+
send_get("get_plan/#{plan_id}", opts)
|
83
84
|
end
|
84
85
|
|
85
86
|
def get_plans(project_id, opts = {})
|
86
|
-
|
87
|
+
send_get("get_plans/#{project_id}", opts)
|
87
88
|
end
|
88
89
|
|
89
90
|
def add_plan(project_id, opts = {})
|
90
|
-
|
91
|
+
send_post("add_plan/#{project_id}", opts)
|
91
92
|
end
|
92
93
|
|
93
94
|
def add_plan_entries(plan_id, opts = {})
|
94
|
-
|
95
|
+
send_post("add_plan_entries/#{plan_id}", opts)
|
95
96
|
end
|
96
97
|
|
97
98
|
def close_plan(plan_id, opts = {})
|
98
|
-
|
99
|
+
send_post("close_plan/#{plan_id}", opts)
|
99
100
|
end
|
100
101
|
|
101
102
|
def get_milestone(milestone_id, opts = {})
|
102
|
-
|
103
|
+
send_get("get_milestone/#{milestone_id}", opts)
|
103
104
|
end
|
104
105
|
|
105
106
|
def get_milestones(project_id, opts = {})
|
106
|
-
|
107
|
+
send_get("get_milestones/#{project_id}", opts)
|
107
108
|
end
|
108
109
|
|
109
110
|
def add_milestone(project_id, opts = {})
|
110
|
-
|
111
|
+
send_post("add_milestone/#{project_id}", opts)
|
111
112
|
end
|
112
113
|
|
113
114
|
def get_project(project_id, opts = {})
|
114
|
-
|
115
|
+
send_get("get_project/#{project_id}", opts)
|
115
116
|
end
|
116
117
|
|
117
118
|
def get_projects(opts = {})
|
118
|
-
|
119
|
+
send_get('get_projects', opts)
|
119
120
|
end
|
120
|
-
end
|
121
|
+
end
|
data/lib/testrail-ruby.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'version'
|
2
2
|
require_relative 'endpoints'
|
3
3
|
require 'net/http'
|
4
4
|
require 'net/https'
|
@@ -10,7 +10,6 @@ require 'json'
|
|
10
10
|
# @client.user = 'UserName'
|
11
11
|
# @client.password = 'Password'
|
12
12
|
|
13
|
-
|
14
13
|
module TestRail
|
15
14
|
class APIClient
|
16
15
|
@url = ''
|
@@ -22,23 +21,20 @@ module TestRail
|
|
22
21
|
attr_accessor :password
|
23
22
|
|
24
23
|
def initialize(base_url)
|
25
|
-
|
26
|
-
base_url += '/'
|
27
|
-
end
|
24
|
+
base_url += '/' unless base_url =~ /\/$/
|
28
25
|
@url = base_url + 'index.php?/api/v2/'
|
29
26
|
end
|
30
27
|
|
31
|
-
|
32
28
|
def send_get(uri, data)
|
33
29
|
_send_request('GET', uri, data)
|
34
30
|
end
|
35
31
|
|
36
|
-
|
37
32
|
def send_post(uri, data)
|
38
33
|
_send_request('POST', uri, data)
|
39
34
|
end
|
40
35
|
|
41
36
|
private
|
37
|
+
|
42
38
|
def _send_request(method, uri, data)
|
43
39
|
url = URI.parse(@url + uri)
|
44
40
|
if method == 'POST'
|
@@ -57,20 +53,20 @@ module TestRail
|
|
57
53
|
end
|
58
54
|
response = conn.request(request)
|
59
55
|
|
60
|
-
if response.body && !response.body.empty?
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
result = if response.body && !response.body.empty?
|
57
|
+
JSON.parse(response.body)
|
58
|
+
else
|
59
|
+
{}
|
60
|
+
end
|
65
61
|
|
66
62
|
if response.code != '200'
|
67
|
-
if result && result.key?('error')
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
raise APIError
|
73
|
-
|
63
|
+
error = if result && result.key?('error')
|
64
|
+
'"' + result['error'] + '"'
|
65
|
+
else
|
66
|
+
'No additional error message received'
|
67
|
+
end
|
68
|
+
raise APIError, 'TestRail API returned HTTP %s (%s)' %
|
69
|
+
[response.code, error]
|
74
70
|
end
|
75
71
|
|
76
72
|
result
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Testrail
|
2
2
|
class Client
|
3
|
-
|
4
3
|
attr_reader :request
|
5
4
|
|
6
5
|
def initialize
|
@@ -131,12 +130,11 @@ module Testrail
|
|
131
130
|
request.get('get_projects', opts)
|
132
131
|
end
|
133
132
|
|
134
|
-
|
135
133
|
# COMMANDS.each do |method_name|
|
136
134
|
# define_method method_name
|
137
135
|
# end
|
138
136
|
|
139
|
-
COMMANDS = %w
|
137
|
+
COMMANDS = %w(add_result
|
140
138
|
add_result_for_case
|
141
139
|
get_test
|
142
140
|
get_tests
|
@@ -164,6 +162,6 @@ module Testrail
|
|
164
162
|
get_milestones
|
165
163
|
add_milestone
|
166
164
|
get_project
|
167
|
-
get_projects
|
165
|
+
get_projects).freeze
|
168
166
|
end
|
169
|
-
end
|
167
|
+
end
|
@@ -2,8 +2,7 @@ require 'logger'
|
|
2
2
|
require 'active_support/configurable'
|
3
3
|
|
4
4
|
module Testrail
|
5
|
-
|
6
|
-
def self.configure(&block)
|
5
|
+
def self.configure
|
7
6
|
@config = Config.new
|
8
7
|
yield @config if block_given?
|
9
8
|
end
|
@@ -22,12 +21,12 @@ module Testrail
|
|
22
21
|
|
23
22
|
def default_config
|
24
23
|
self.headers = {
|
25
|
-
|
24
|
+
'Accept' => 'application/json'
|
26
25
|
}
|
27
|
-
self.server =
|
28
|
-
self.api_path =
|
26
|
+
self.server = 'https://example.testrail.com'
|
27
|
+
self.api_path = '/index.php?/miniapi/'
|
29
28
|
self.api_key = nil
|
30
29
|
self.logger = Logger.new STDOUT
|
31
30
|
end
|
32
31
|
end
|
33
|
-
end
|
32
|
+
end
|
@@ -31,12 +31,12 @@ module Testrail
|
|
31
31
|
log_error error, "Timeout connecting to #{method.to_s.upcase} #{url}"
|
32
32
|
raise error
|
33
33
|
rescue Exception => error
|
34
|
-
log_error error,
|
34
|
+
log_error error, 'Unexpected exception intercepted calling TestRail'
|
35
35
|
raise error
|
36
36
|
end
|
37
37
|
response
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def self.log_error(error, message)
|
41
41
|
unless Testrail.logger.nil?
|
42
42
|
Testrail.logger.error message
|
@@ -5,7 +5,7 @@ module Testrail
|
|
5
5
|
class Response
|
6
6
|
attr_reader :http_response
|
7
7
|
attr_accessor :success, :payload, :error
|
8
|
-
|
8
|
+
|
9
9
|
extend Forwardable
|
10
10
|
|
11
11
|
def_delegators :http_response, :request, :response, :code
|
@@ -17,6 +17,7 @@ module Testrail
|
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
|
+
|
20
21
|
def parse_payload
|
21
22
|
result_body = JSON.parse(http_response.body)
|
22
23
|
@success = result_body.key?('result') ? result_body.delete('result') : nil
|
@@ -32,4 +33,4 @@ module Testrail
|
|
32
33
|
@error = ::Net::HTTPResponse::CODE_TO_OBJ[http_response.code.to_s].name.gsub!(/Net::HTTP/, '')
|
33
34
|
end
|
34
35
|
end
|
35
|
-
end
|
36
|
+
end
|
data/lib/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Testrail
|
2
|
-
VERSION = '0.0.
|
1
|
+
module Testrail
|
2
|
+
VERSION = '0.0.4'.freeze
|
3
3
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'testrail/ruby'
|
3
3
|
|
4
4
|
RSpec.configure do |config|
|
5
5
|
# Enable flags like --only-failures and --next-failure
|
6
|
-
config.example_status_persistence_file_path =
|
6
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
7
7
|
|
8
8
|
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
9
|
config.disable_monkey_patching!
|
data/spec/testrail/ruby_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe Testrail::Ruby do
|
4
|
-
it
|
4
|
+
it 'has a version number' do
|
5
5
|
expect(Testrail::Ruby::VERSION).not_to be nil
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'does something useful' do
|
9
9
|
expect(false).to eq(true)
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testrail-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frances Morales
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.4.8
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Client wrapper in Ruby for TestRail API (v2)
|