cukerail 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79f05604565fe68cea1631b80c6627ce31b8407e
4
- data.tar.gz: 5a8729dd85cef095455869f98fcca70bd643f436
3
+ metadata.gz: d0b379455c3a2bfece21f51c89c286f5a27e2814
4
+ data.tar.gz: 7690535fd04963b629039dde58c9ba47961cc7a8
5
5
  SHA512:
6
- metadata.gz: ece6e0a05572fc1705fdcf76ffb2caa03867c52a3d1f14ad2a48784ab24e913c64b351667df84bd3704fadcd0e4a0ef1356e22bfcc39863388a2d7c0906d613d
7
- data.tar.gz: 6091144fd6996b46076d81d0f1c5c7c956c8fa476175eb815875a48434c1ac0adb0c4ca3357b88210d1261753d6be0bfd9701a42ca683456046426c4dde1f526
6
+ metadata.gz: 96891be91b5458858837a4d5211e8445f12a9a926b9e3821a0ca73a3dbf611cb99048cf8d0647f7fd97d3a2b9fcb8aad3715158ac428e3ef639274a2c6ccc80c
7
+ data.tar.gz: bfe3178523c78c2e9bb5f530f6dc9d37ecc9a7249f7027b3450688a46672482f26ae21533cdaabc11371a4753e95eaa1c14df2242d12aa80603b91d98a3d328e
@@ -1,3 +1,3 @@
1
1
  module Cukerail
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/cukerail.rb CHANGED
@@ -4,7 +4,6 @@ module Cukerail
4
4
  class Sender
5
5
  attr_reader :testrail_api_client,:failed_step
6
6
  def initialize(runtime, io, options)
7
- puts 'in initialize'
8
7
  if %w(BASE_URL USER PASSWORD).map{|e| ENV["TESTRAIL_#{e}"]}.any?{|e| e=='' || !e}
9
8
  raise 'You need to setup Testrail environment parameters see https://bbcworldwide.atlassian.net/wiki/display/BAR/Installing+and+Running+Cukerail'
10
9
  end
@@ -88,8 +87,8 @@ module Cukerail
88
87
 
89
88
  def send_steps(test_case,id)
90
89
  steps_as_string = test_case.test_steps.map{|step| step.source.last}
91
- .select{|step| step.is_a?(Cucumber::Core::Ast::Step) && step.respond_to?(:gherkin_statement)}
92
- .reject{|step| step.is_a?(Cucumber::Hooks::BeforeHook)}.map do | step |
90
+ .select{|step| step.is_a?(Cucumber::Core::Ast::Step) && step.respond_to?(:gherkin_statement)}
91
+ .reject{|step| step.is_a?(Cucumber::Hooks::BeforeHook)}.map do | step |
93
92
  g = step.gherkin_statement
94
93
  str = g.keyword+g.name
95
94
  g.rows.each do | row |
@@ -102,7 +101,7 @@ module Cukerail
102
101
  'type_id'=>(is_manual ? 7 : 1 ),
103
102
  'custom_steps'=>steps_as_string,
104
103
  'refs'=>defects(test_case)
105
- }
104
+ }
106
105
  testrail_api_client.send_post("update_case/#{id}",data)
107
106
  end
108
107
 
@@ -113,7 +112,7 @@ module Cukerail
113
112
  'type_id'=>(is_manual ? 7 : 1 ),
114
113
  'custom_steps'=>steps_as_string,
115
114
  'refs'=>defects(test_case)
116
- }
115
+ }
117
116
  testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}", data)
118
117
  end
119
118
 
@@ -149,7 +148,12 @@ module Cukerail
149
148
  begin
150
149
  testrail_api_client.send_post("add_result_for_case/#{testrun}/#{id}",report_on_result)
151
150
  rescue => e
152
- puts "#{e.message} testrun=#{testrun} test case id=#{id}"
151
+ if e.message =~ /No \(active\) test found for the run\/case combination/
152
+ add_case_to_test_run(id,testrun)
153
+ retry
154
+ else
155
+ puts "#{e.message} testrun=#{testrun} test case id=#{id}"
156
+ end
153
157
  end
154
158
  end
155
159
 
@@ -164,6 +168,14 @@ module Cukerail
164
168
  [requirements_tags,title].compact.join(' ').strip
165
169
  end
166
170
 
171
+ def get_run(run_id)
172
+ testrail_api_client.send_get("get_run/#{run_id}")
173
+ end
174
+
175
+ def get_tests_in_a_run(run_id)
176
+ testrail_api_client.send_get("get_tests/#{run_id}")
177
+ end
178
+
167
179
  def all_tags(test_case)
168
180
  test_case.tags + test_case.feature.tags
169
181
  end
@@ -172,6 +184,31 @@ module Cukerail
172
184
  all_tags(test_case).select{|tag| tag.name =~/jira_/}.map{|ticket| /STORE-\d+/.match(ticket.name)[0]}.join(" ")
173
185
  end
174
186
 
187
+ def update_run(testrun,case_ids)
188
+ begin
189
+ testrail_api_client.send_post("update_run/#{testrun}",case_ids)
190
+ rescue => e
191
+ puts "#{e.message} testrun=#{testrun} test case ids=#{case_ids}"
192
+ end
193
+ end
194
+
195
+ def remove_case_from_test_run(testcase,testrun)
196
+ testcase_id = get_id(testcase)
197
+ run = get_run(testrun)
198
+ unless run['include_all']
199
+ case_ids = get_tests_in_a_run(testrun).map{|h| h['case_id']} - [testcase_id]
200
+ update_run(testrun,{'case_ids'=>case_ids})
201
+ end
202
+ end
203
+
204
+ def add_case_to_test_run(testcase_id,testrun)
205
+ run = get_run(testrun)
206
+ unless run['include_all']
207
+ case_ids = get_tests_in_a_run(testrun).map{|h| h['case_id']} + [testcase_id]
208
+ update_run(testrun,{'case_ids'=>case_ids})
209
+ end
210
+ end
211
+
175
212
  end
176
213
 
177
214
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukerail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Small
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-29 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler