gridium 0.2.3 → 0.2.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: c5b97b15990a724513d715ccb5e84c83078bee0b
4
- data.tar.gz: e49dc32244857906d0f321a04d254eacc96887d4
3
+ metadata.gz: 46d996e7c1fc5e700bf68f655503ef6e2eb3c6fd
4
+ data.tar.gz: b3c5bfdb542a3bcaa0b98723401a2fab985d6b98
5
5
  SHA512:
6
- metadata.gz: 23e6df5a7e7e18bf49181af7fcde59a19420c1d75bc96f29b3bff1847c70745d8d9f56fa4b13b3cdeecd0caf69d901f3de37cb3fecc859c0c05c5c03f38f8f38
7
- data.tar.gz: fdfc5ad5f910a07a4395707db65d4f165fef6667f660894098595869c0d99638f828bd4bd11b1b870fc426587583f3c030ed3d6bc684c3680be9fb48887abdbb
6
+ metadata.gz: a89978028aed88aed4c75d2d379daed93fcb86b6b9f4fc74dfe5a58cfbf940827211b6125192d496ec88aec37c8704288a55c62ed0c167af31e47a8cd125c637
7
+ data.tar.gz: f933eca0a1ad6bd394cf9f56228162550b5368d17eed12a7713798d9bcad3f8e065d19796ea9205201d695f402fcc9f2031f498cd5c7a5d52ee6f49474f67682
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.3.1
4
4
  before_install: gem install bundler -v 1.10.3
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.pattern = 'spec/testrail_spec.rb'
6
+ end
5
7
 
6
8
  task :default => :spec
@@ -1,3 +1,3 @@
1
1
  module Gridium
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -20,6 +20,8 @@ module Gridium
20
20
  @user = ENV['GRIDIUM_TR_USER'].empty? || ENV['GRIDIUM_TR_USER'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_USER']
21
21
  @password = ENV['GRIDIUM_TR_PW'].empty? || ENV['GRIDIUM_TR_PW'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_PW']
22
22
  @pid = ENV['GRIDIUM_TR_PID'].empty? || ENV['GRIDIUM_TR_PID'].nil? ? ENV_ERROR : ENV['GRIDIUM_TR_PID']
23
+ @testcase_ids = Array.new
24
+ @testcase_infos = Array.new
23
25
  end
24
26
  end
25
27
 
@@ -37,44 +39,48 @@ module Gridium
37
39
  end
38
40
  end
39
41
 
40
- def close_run
41
- if Gridium.config.testrail
42
- Log.debug("[GRIDIUM::TestRail] Closing RunID: #{@runid}")
43
- unless @runid.nil?
44
- r = _send_request('POST', "close_run/#{@runid}", nil)
45
- end
46
- end
47
- end
48
-
49
- def add_case(rspec_test)
50
- if Gridium.config.testrail
51
- Log.debug("[GRIDIUM::TestRail] Adding case: #{rspec_test} for RunID: #{@runid}")
52
- if rspec_test.nil? then
53
- raise(ArgumentError, "No test data was passed in.")
54
- end
55
- unless @runid.nil?
56
- r = _send_request('POST', "update_run/#{@runid}", {:case_ids => [rspec_test.metadata[:testrail_id]]})
57
- if rspec_test.exception
58
- status = FAILED
59
- message = rspec_test.exception.message
60
- else
61
- status = PASSED
62
- message = ''
63
- end
64
- r = _send_request(
65
- 'POST',
66
- "add_result_for_case/#{@runid}/#{rspec_test.metadata[:testrail_id]}",
67
- status_id: status,
68
- comment: message
69
- )
70
- end
71
- end
72
- end
42
+ def add_case(rspec_test)
43
+ if Gridium.config.testrail
44
+ Log.debug("[GRIDIUM::TestRail] Adding to list of TestRail Cases...")
45
+ if rspec_test.nil? then
46
+ Log.error("[GRIDIUM::TestRail] No test added to results. Turn of Gridium.config.testrail\n")
47
+ end
48
+ if rspec_test.exception
49
+ status = FAILED
50
+ message = rspec_test.exception.message
51
+ else
52
+ status = PASSED
53
+ message = 'Test Passed.'
54
+ end
55
+ test_info = {:trid => rspec_test.metadata[:testrail_id], :status_id => status, :message => message}
56
+ @testcase_infos.push(test_info)
57
+ @testcase_ids.push(test_info[:trid])
58
+ end
59
+ end
73
60
 
61
+ def close_run
62
+ if Gridium.config.testrail
63
+ Log.debug("[GRIDIUM::TestRail] Closing test runid: #{@runid}\n")
64
+ unless @runid.nil?
65
+ r = _send_request('POST', "update_run/#{@runid}", {:case_ids => @testcase_ids})
66
+ @testcase_infos.each do |tc|
67
+ r = _send_request(
68
+ 'POST',
69
+ "add_result_for_case/#{@runid}/#{tc[:trid]}",
70
+ status_id: tc[:status_id],
71
+ comment: tc[:message]
72
+ )
73
+ sleep(0.25)
74
+ end
75
+ r = _send_request('POST', "close_run/#{@runid}", nil)
76
+ end
77
+ end
78
+ end
74
79
 
75
80
  private
76
81
  def _send_request(method, uri, data)
77
82
  url = URI.parse(@url + uri)
83
+ Log.debug("[GRIDIUM::TestRail] Method: #{method} URL:#{uri} Data:#{data}")
78
84
  if method == 'POST'
79
85
  request = Net::HTTP::Post.new(url.path + '?' + url.query)
80
86
  request.body = JSON.dump(data)
@@ -90,7 +96,6 @@ module Gridium
90
96
  conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
91
97
  end
92
98
  response = conn.request(request)
93
-
94
99
  if response.body && !response.body.empty?
95
100
  result = JSON.parse(response.body)
96
101
  else
@@ -98,11 +103,13 @@ module Gridium
98
103
  end
99
104
 
100
105
  if response.code != '200'
106
+
101
107
  if result && result.key?('error')
102
108
  error = '"' + result['error'] + '"'
103
109
  else
104
110
  error = 'No additional error message received'
105
111
  end
112
+ Log.debug("[GRIDIUM::TestRail] Error with request: #{error}")
106
113
  raise APIError.new('TestRail API returned HTTP %s (%s)' %
107
114
  [response.code, error])
108
115
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler