telly 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/telly.rb +22 -14
  2. metadata +22 -14
  3. checksums.yaml +0 -7
data/lib/telly.rb CHANGED
@@ -5,6 +5,7 @@ require 'yaml'
5
5
  require 'pp'
6
6
  require 'testrail'
7
7
 
8
+
8
9
  # == telly.rb
9
10
  # This module provides functions to add test results in testrail from a
10
11
  # finished beaker run.
@@ -23,6 +24,11 @@ require 'testrail'
23
24
  # and a test status.""
24
25
  module Telly
25
26
 
27
+ # This exception is thrown when a testcase ID can't be found in a beaker
28
+ # script. It's meant to be caught and shown to the user as a warning
29
+ class MissingTestRailId < StandardError
30
+ end
31
+
26
32
  TESTRAIL_URL = 'https://testrail.ops.puppetlabs.net/'
27
33
  CREDENTIALS_FILE = '~/.testrail_credentials.yaml'
28
34
 
@@ -132,8 +138,8 @@ module Telly
132
138
  # passes
133
139
  results[:passes].each do |junit_result|
134
140
  begin
135
- submit_result(api, PASSED, junit_result, junit_file, testrun_id)
136
- rescue TestRail::APIError => e
141
+ submit_result(api, PASSED, junit_result, junit_file, testrun_id)
142
+ rescue MissingTestRailId, TestRail::APIError => e
137
143
  bad_results[junit_result[:name]] = e.message
138
144
  end
139
145
  end
@@ -141,8 +147,8 @@ module Telly
141
147
  # Failures
142
148
  results[:failures].each do |junit_result|
143
149
  begin
144
- submit_result(api, FAILED, junit_result, junit_file, testrun_id)
145
- rescue TestRail::APIError => e
150
+ submit_result(api, FAILED, junit_result, junit_file, testrun_id)
151
+ rescue MissingTestRailId, TestRail::APIError => e
146
152
  bad_results[junit_result[:name]] = e.message
147
153
  end
148
154
  end
@@ -150,8 +156,8 @@ module Telly
150
156
  # Skips
151
157
  results[:skips].each do |junit_result|
152
158
  begin
153
- submit_result(api, BLOCKED, junit_result, junit_file, testrun_id)
154
- rescue TestRail::APIError => e
159
+ submit_result(api, BLOCKED, junit_result, junit_file, testrun_id)
160
+ rescue MissingTestRailId, TestRail::APIError => e
155
161
  bad_results[junit_result[:name]] = e.message
156
162
  end
157
163
  end
@@ -168,7 +174,7 @@ module Telly
168
174
  # @param [String] testrun_id The testrun ID
169
175
  #
170
176
  # @return [Void]
171
- #
177
+ #
172
178
  # @raise [TestRail::APIError] When there is a problem with the API request, testrail raises
173
179
  # this exception. Should be caught for error reporting
174
180
  #
@@ -196,7 +202,7 @@ module Telly
196
202
  puts "\nSetting result for test case: #{testcase_id}"
197
203
  puts "Adding comment:\n#{testrail_comment}"
198
204
 
199
- api.send_post("add_result_for_case/#{testrun_id}/#{testcase_id}",
205
+ api.send_post("add_result_for_case/#{testrun_id}/#{testcase_id}",
200
206
  {
201
207
  status_id: status,
202
208
  comment: testrail_comment,
@@ -207,10 +213,10 @@ module Telly
207
213
 
208
214
 
209
215
  # Returns a string that testrail accepts as an elapsed time
210
- # Input from beaker is a float in seconds, so it rounds it to the
216
+ # Input from beaker is a float in seconds, so it rounds it to the
211
217
  # nearest second, and adds an 's' at the end
212
- #
213
- # Testrail throws an exception if it gets "0s", so it returns a
218
+ #
219
+ # Testrail throws an exception if it gets "0s", so it returns a
214
220
  # minimum of "1s"
215
221
  #
216
222
  # @param [String] seconds_string A string that contains only a number, the elapsed time of a test
@@ -233,11 +239,11 @@ module Telly
233
239
  ##################################
234
240
 
235
241
  # Loads the results of a beaker run.
236
- # Returns hash of failures, passes, and skips that each hold a list of
242
+ # Returns hash of failures, passes, and skips that each hold a list of
237
243
  # junit xml objects
238
244
  #
239
245
  # @param [String] junit_file Path to a junit xml file
240
- #
246
+ #
241
247
  # @return [Hash] A hash containing xml objects for the failures, skips, and passes
242
248
  #
243
249
  # @example load_junit_results("~/junit/latest/beaker_junit.xml")
@@ -255,7 +261,7 @@ module Telly
255
261
  # Extracts the test case id from the test script
256
262
  #
257
263
  # @param [String] beaker_file Path to a beaker test script
258
- #
264
+ #
259
265
  # @return [String] The test case ID
260
266
  #
261
267
  # @example testcase_id_from_beaker_script("~/tests/test_the_things.rb") # 1234
@@ -263,6 +269,8 @@ module Telly
263
269
  # Find first matching line
264
270
  match = File.readlines(beaker_file).map { |line| line.match(TESTCASE_ID_REGEX) }.compact.first
265
271
 
272
+ raise MissingTestRailId, 'Testcase ID could not be found in file' if match.nil?
273
+
266
274
  match[:testrun_id]
267
275
  end
268
276
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Joe Pinsonault
@@ -9,48 +10,54 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-12-15 00:00:00.000000000 Z
13
+ date: 2015-02-13 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: webmock
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - ">="
20
+ - - ! '>='
19
21
  - !ruby/object:Gem::Version
20
22
  version: '0'
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
- - - ">="
28
+ - - ! '>='
26
29
  - !ruby/object:Gem::Version
27
30
  version: '0'
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: nokogiri
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
- - - ">="
36
+ - - ! '>='
33
37
  - !ruby/object:Gem::Version
34
38
  version: '0'
35
39
  type: :runtime
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
- - - ">="
44
+ - - ! '>='
40
45
  - !ruby/object:Gem::Version
41
46
  version: '0'
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: rspec
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
- - - ">="
52
+ - - ! '>='
47
53
  - !ruby/object:Gem::Version
48
54
  version: '0'
49
55
  type: :development
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
52
59
  requirements:
53
- - - ">="
60
+ - - ! '>='
54
61
  - !ruby/object:Gem::Version
55
62
  version: '0'
56
63
  description: Imports beaker results into TestRail test run results
@@ -60,31 +67,32 @@ executables:
60
67
  extensions: []
61
68
  extra_rdoc_files: []
62
69
  files:
63
- - bin/telly
64
70
  - lib/telly.rb
65
71
  - lib/testrail.rb
72
+ - bin/telly
66
73
  homepage: http://rubygems.org/gems/telly
67
74
  licenses:
68
75
  - Apache
69
- metadata: {}
70
76
  post_install_message:
71
77
  rdoc_options: []
72
78
  require_paths:
73
79
  - lib
74
80
  required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
75
82
  requirements:
76
- - - ">="
83
+ - - ! '>='
77
84
  - !ruby/object:Gem::Version
78
85
  version: '0'
79
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
80
88
  requirements:
81
- - - ">="
89
+ - - ! '>='
82
90
  - !ruby/object:Gem::Version
83
91
  version: '0'
84
92
  requirements: []
85
93
  rubyforge_project:
86
- rubygems_version: 2.4.5
94
+ rubygems_version: 1.8.23
87
95
  signing_key:
88
- specification_version: 4
96
+ specification_version: 3
89
97
  summary: Imports beaker results into TestRail test run results
90
98
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: daa063e14ee499acd934b81ead0304419094190b
4
- data.tar.gz: a8f8240fe98212a75bca1f81c722981b735930cf
5
- SHA512:
6
- metadata.gz: 9060bdcd028c788d6c2224b591d342d905510e2f9f75fab049ef4d8f92a241139d7d27888ae07d64141bfdc6958e54c81ddea93e6e907b205e6eb09a3a1ec4ec
7
- data.tar.gz: 0f8d56d22cbccfe8d6e88650f2ab480db43bf88e561d003d40213f0aa224ad9efda3291e52d90f8cfbd8ce29b1bcd063acc2e6fd4b9adf33cb45f18cb4e070f4