cukerail 0.3.3 → 0.3.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: 1b831a4b870d9c07024277f6cb8e9b5251b41c40
4
- data.tar.gz: 75d6bed3146b9a653d898cc708eac9a137e6517f
3
+ metadata.gz: e5bafd2e3713f9bc90f2555a9f01581df6ae2420
4
+ data.tar.gz: 78579041ab618d9b636639c374e7493b8ba2c843
5
5
  SHA512:
6
- metadata.gz: 6406952e4048f47c1677160d029c202d2788f0b171d29a754600c11b993675e2e3884f7346e1960c822d6f295a513668c79d666fd356ac81361699f3e96e75bb
7
- data.tar.gz: dd193e68dff1c5211f266fef9e097902f36613d2a16b3acc7898eee5df4fc72bfa5c3d7b9fc63f882246e08da8d29ebb6a68d93e8685350fce8f6f6341222363
6
+ metadata.gz: e01b06f772ded6ed2cc164b83a3fd31540b2d515ab76c06fa909775879ad81cb7ac768a073fe3e4bf6603939aba58d437924121600345b0e442035bac1188243
7
+ data.tar.gz: 4de9899654fe18a1dfa0f4d12265001a57d36f55f722a8cc99813e6130b2208c30a15a39a066d07806815430e07b8d870741b1f309c0732a05697269da1ee58e
@@ -1,3 +1,3 @@
1
1
  module Cukerail
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/lib/json_sender.rb CHANGED
@@ -76,14 +76,14 @@ module Cukerail
76
76
 
77
77
  def defects(scenario)
78
78
  if scenario['tags']
79
- scenario['tags'].select{|t| t['name'] =~/@jira_/}.map{|t| /jira_(\w+-\w+)/.match(t['name'])}.join(' ')
79
+ scenario['tags'].select{|t| t['name'] =~/@jira_/}.map{|t| /jira_(\w+-\d+)/.match(t['name'])[1]}.join(' ')
80
80
  end
81
81
  end
82
82
 
83
- def send_result(scenario,id,testrun)
83
+ def send_result(scenario,id,testrun_id)
84
84
  error_line = scenario['steps'].select{|s| s['result']['status'] != 'passed'}.first
85
85
  if error_line
86
- puts error_line['result']
86
+ #puts error_line['result']
87
87
  testrail_status = case error_line['result']['status']
88
88
  when 'failed'
89
89
  {id:5,comment: 'failed'}
@@ -106,37 +106,44 @@ module Cukerail
106
106
  end
107
107
  report_on_result = {status_id:testrail_status[:id],comment:failure_message,defects:defects(scenario)}
108
108
  begin
109
- testrail_api_client.send_post("add_result_for_case/#{testrun}/#{id}",report_on_result)
109
+ testrail_api_client.send_post("add_result_for_case/#{testrun_id}/#{id}",report_on_result)
110
110
  rescue => e
111
111
  if e.message =~ /No \(active\) test found for the run\/case combination/
112
- add_case_to_test_run(id,testrun)
112
+ add_case_to_test_run(id,testrun_id)
113
113
  retry
114
114
  else
115
- puts "#{e.message} testrun=#{testrun} test case id=#{id}"
115
+ puts "#{e.message} testrun=#{testrun_id} test case id=#{id}"
116
116
  end
117
117
  end
118
118
  end
119
119
 
120
120
  def get_run(run_id)
121
- @test_run ||= testrail_api_client.send_get("get_run/#{run_id}")
122
- ap @test_run
123
- puts "test plan = #{@test_run['plan_id']}"
124
- @test_run
121
+ testrail_api_client.send_get("get_run/#{run_id}")
125
122
  end
126
123
 
127
124
  def get_tests_in_a_run(run_id)
128
- @all_tests ||= testrail_api_client.send_get("get_tests/#{run_id}")
125
+ testrail_api_client.send_get("get_tests/#{run_id}")
129
126
  end
130
127
 
131
128
  def update_run(testrun_id,case_ids)
132
129
  run = get_run(testrun_id)
133
130
  begin
134
- testrail_api_client.send_post("update_run/#{testrun_id}",case_ids)
131
+ if run['plan_id']
132
+ update_plan(run['plan_id'],testrun_id,case_ids)
133
+ else
134
+ testrail_api_client.send_post("update_run/#{testrun_id}",case_ids)
135
+ end
135
136
  rescue => e
136
137
  puts "#{e.message} testrun=#{testrun_id} test case ids=#{case_ids}"
137
138
  end
138
139
  end
139
140
 
141
+ def update_plan(plan_id,testrun_id,case_ids)
142
+ test_plan = testrail_api_client.send_get("get_plan/#{plan_id}")
143
+ entry_id = test_plan['entries'].select{|e| e['runs'].any?{|r| r['id']==testrun_id}}.first['id']
144
+ testrail_api_client.send_post("update_plan_entry/#{plan_id}/#{entry_id}",case_ids)
145
+ end
146
+
140
147
  def remove_case_from_test_run(testcase,testrun_id)
141
148
  testcase_id = get_id(testcase)
142
149
  run = get_run(testrun_id)
@@ -146,7 +153,7 @@ module Cukerail
146
153
  end
147
154
  end
148
155
 
149
- def add_case_to_test_run(testcase_id,testrun)
156
+ def add_case_to_test_run(testcase_id,testrun_id)
150
157
  run = get_run(testrun_id)
151
158
  unless run['include_all']
152
159
  case_ids = get_tests_in_a_run(testrun_id).map{|h| h['case_id']} + [testcase_id]
@@ -30,7 +30,7 @@ task :load_to_test_run do
30
30
  testcase_id = json_sender.get_id(scenario,background_steps,project_id,suite_id,sub_section_id)
31
31
  puts "scenario_id #{scenario['id']} testcase_id = #{testcase_id}"
32
32
  json_sender.send_steps(scenario,background_steps,testcase_id)
33
- json_sender.send_result(scenario,testcase_id,ENV['TESTRUN'])
33
+ json_sender.send_result(scenario,testcase_id,ENV['TESTRUN'].to_i)
34
34
  end
35
35
  end
36
36
  end
@@ -46,7 +46,7 @@ task :remove_from_test_run do
46
46
  testcase_ids << json_sender.get_id(scenario,background_steps,project_id,suite_id,sub_section_id)
47
47
  end
48
48
  end
49
- json_sender.remove_all_except_these_cases_from_testrun(testcase_ids,ENV['TESTRUN'])
49
+ json_sender.remove_all_except_these_cases_from_testrun(testcase_ids,ENV['TESTRUN'].to_i)
50
50
  end
51
51
 
52
52
  desc "match test run cases to json results file"
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.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Small
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-18 00:00:00.000000000 Z
11
+ date: 2016-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler