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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 476a1d78ba3f06eaa415748f5e2475a882131ba7
4
- data.tar.gz: 57750f87a18ee141150f7a9399d565714bf4cd76
3
+ metadata.gz: d7dc968b6ee60b0fbe59877dc0c4e1d381dbcbed
4
+ data.tar.gz: 104a5671fec2a629e9a2ce442058ed4d35d0a1e4
5
5
  SHA512:
6
- metadata.gz: 9ceb185f0019e341cd9e6cd09bc20d9213b05a7977d8df093c8c37f2dbb4c19fe0f292121da4434e2fd46f4eab3cf3bbdc6dab0f8b1203fac9d761a4961205f4
7
- data.tar.gz: cf0eb4b77f78d447bb0b605e3b723f8d8411ab511d0d9bb9cc64d631449d9da5148612d981c7c6cc4c316831f97ae9560678a5ae782b8e568513f14a18f2995f
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 GitHub at https://github.com/[USERNAME]/testrail-ruby.
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
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -4,117 +4,118 @@
4
4
  #
5
5
  module Endpoints
6
6
  def add_result(test_id, opts = {})
7
- self.send_post("add_result/#{test_id}", opts)
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
- self.send_post("add_result_for_case/#{run_id}/#{case_id}", opts)
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
- self.send_get("get_test/#{test_id}", opts)
15
+ send_get("get_test/#{test_id}", opts)
16
16
  end
17
17
 
18
18
  def get_tests(run_id, opts = {})
19
- self.send_get("get_tests/#{run_id}", opts)
19
+ send_get("get_tests/#{run_id}", opts)
20
20
  end
21
21
 
22
22
  def get_case(case_id, opts = {})
23
- self.send_get("get_case/#{case_id}", opts)
23
+ send_get("get_case/#{case_id}", opts)
24
24
  end
25
25
 
26
26
  def get_cases(suite_id, section_id, opts = {})
27
- self.send_get("get_cases/#{suite_id}/#{section_id}", opts)
27
+ send_get("get_cases/#{suite_id}/#{section_id}", opts)
28
28
  end
29
29
 
30
30
  def add_case(section_id, opts = {})
31
- self.send_post("add_case/#{section_id}", opts)
31
+ send_post("add_case/#{section_id}", opts)
32
32
  end
33
33
 
34
34
  def update_case(case_id, opts = {})
35
- self.send_post("update_case/#{case_id}", opts)
35
+ send_post("update_case/#{case_id}", opts)
36
36
  end
37
37
 
38
38
  def delete_case(case_id, opts = {})
39
- self.send_post("delete_case/#{case_id}", opts)
39
+ send_post("delete_case/#{case_id}", opts)
40
40
  end
41
+
41
42
  def get_suite(suite_id, opts = {})
42
- self.send_get("get_suite/#{suite_id}", opts)
43
+ send_get("get_suite/#{suite_id}", opts)
43
44
  end
44
45
 
45
46
  def get_suites(project_id, opts = {})
46
- self.send_get("get_suites/#{project_id}", opts)
47
+ send_get("get_suites/#{project_id}", opts)
47
48
  end
48
49
 
49
50
  def get_section(section_id, opts = {})
50
- self.send_get("get_section/#{section_id}", opts)
51
+ send_get("get_section/#{section_id}", opts)
51
52
  end
52
53
 
53
54
  def get_sections(suite_id, opts = {})
54
- self.send_get("get_sections/#{suite_id}", opts)
55
+ send_get("get_sections/#{suite_id}", opts)
55
56
  end
56
57
 
57
58
  def add_suite(project_id, opts = {})
58
- self.send_post("add_suite/#{project_id}", opts)
59
+ send_post("add_suite/#{project_id}", opts)
59
60
  end
60
61
 
61
62
  def add_section(suite_id, opts = {})
62
- self.send_post("add_section/#{suite_id}", opts)
63
+ send_post("add_section/#{suite_id}", opts)
63
64
  end
64
65
 
65
66
  def get_run(run_id, opts = {})
66
- self.send_get("get_run/#{run_id}", opts)
67
+ send_get("get_run/#{run_id}", opts)
67
68
  end
68
69
 
69
70
  def get_runs(project_id, plan_id, opts = {})
70
- self.send_get("get_runs/#{project_id}/#{plan_id}", opts)
71
+ send_get("get_runs/#{project_id}/#{plan_id}", opts)
71
72
  end
72
73
 
73
74
  def add_run(suite_id, opts = {})
74
- self.send_post("add_run/#{suite_id}", opts)
75
+ send_post("add_run/#{suite_id}", opts)
75
76
  end
76
77
 
77
78
  def close_run(run_id, opts = {})
78
- self.send_post("close_run/#{run_id}", opts)
79
+ send_post("close_run/#{run_id}", opts)
79
80
  end
80
81
 
81
82
  def get_plan(plan_id, opts = {})
82
- self.send_get("get_plan/#{plan_id}", opts)
83
+ send_get("get_plan/#{plan_id}", opts)
83
84
  end
84
85
 
85
86
  def get_plans(project_id, opts = {})
86
- self.send_get("get_plans/#{project_id}", opts)
87
+ send_get("get_plans/#{project_id}", opts)
87
88
  end
88
89
 
89
90
  def add_plan(project_id, opts = {})
90
- self.send_post("add_plan/#{project_id}", opts)
91
+ send_post("add_plan/#{project_id}", opts)
91
92
  end
92
93
 
93
94
  def add_plan_entries(plan_id, opts = {})
94
- self.send_post("add_plan_entries/#{plan_id}", opts)
95
+ send_post("add_plan_entries/#{plan_id}", opts)
95
96
  end
96
97
 
97
98
  def close_plan(plan_id, opts = {})
98
- self.send_post("close_plan/#{plan_id}", opts)
99
+ send_post("close_plan/#{plan_id}", opts)
99
100
  end
100
101
 
101
102
  def get_milestone(milestone_id, opts = {})
102
- self.send_get("get_milestone/#{milestone_id}", opts)
103
+ send_get("get_milestone/#{milestone_id}", opts)
103
104
  end
104
105
 
105
106
  def get_milestones(project_id, opts = {})
106
- self.send_get("get_milestones/#{project_id}", opts)
107
+ send_get("get_milestones/#{project_id}", opts)
107
108
  end
108
109
 
109
110
  def add_milestone(project_id, opts = {})
110
- self.send_post("add_milestone/#{project_id}", opts)
111
+ send_post("add_milestone/#{project_id}", opts)
111
112
  end
112
113
 
113
114
  def get_project(project_id, opts = {})
114
- self.send_get("get_project/#{project_id}", opts)
115
+ send_get("get_project/#{project_id}", opts)
115
116
  end
116
117
 
117
118
  def get_projects(opts = {})
118
- self.send_get("get_projects", opts)
119
+ send_get('get_projects', opts)
119
120
  end
120
- end
121
+ end
@@ -1,4 +1,4 @@
1
- require_relative "version"
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
- if !base_url.match(/\/$/)
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
- result = JSON.parse(response.body)
62
- else
63
- result = {}
64
- end
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
- error = '"' + result['error'] + '"'
69
- else
70
- error = 'No additional error message received'
71
- end
72
- raise APIError.new('TestRail API returned HTTP %s (%s)' %
73
- [response.code, error])
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[add_result
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
@@ -10,6 +10,7 @@ module Testrail
10
10
  end
11
11
 
12
12
  private
13
+
13
14
  def key
14
15
  '&key=' + String(Testrail.config.api_key)
15
16
  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
- "Accept" => "application/json"
24
+ 'Accept' => 'application/json'
26
25
  }
27
- self.server = "https://example.testrail.com"
28
- self.api_path = "/index.php?/miniapi/"
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, "Unexpected exception intercepted calling TestRail"
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
@@ -1,3 +1,3 @@
1
- module Testrail
2
- VERSION = '0.0.3'
1
+ module Testrail
2
+ VERSION = '0.0.4'.freeze
3
3
  end
@@ -1,9 +1,9 @@
1
- require "bundler/setup"
2
- require "testrail/ruby"
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 = ".rspec_status"
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!
@@ -1,11 +1,11 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  RSpec.describe Testrail::Ruby do
4
- it "has a version number" do
4
+ it 'has a version number' do
5
5
  expect(Testrail::Ruby::VERSION).not_to be nil
6
6
  end
7
7
 
8
- it "does something useful" do
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.3
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-07 00:00:00.000000000 Z
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.6.10
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)