cukerail 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cukerail/version.rb +1 -1
- data/lib/cukerail.rb +25 -15
- data/lib/json_sender.rb +12 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcb1e0a9b7c38f50b8804df39b29e0157077591c
|
4
|
+
data.tar.gz: fe105c55011ce966dd6105019bce6d0b9d33824b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0482e90c13c1e1ac3403c4b531a48a59a5863b15b6a7ed007b6676a3092f793bf991f6bb3310156a75a4d22f00d6ae40fd65ed138f138adde1ffd6b077445268
|
7
|
+
data.tar.gz: bdfd582e2d35f50decab8e2dd35e948a376b6f36af968934741bc43c2fcb23532408d387d6c74b637eaf0c98519b40e2fbf1bb9181a9f8059ba4e8e990bf8b55
|
data/lib/cukerail/version.rb
CHANGED
data/lib/cukerail.rb
CHANGED
@@ -23,6 +23,9 @@ module Cukerail
|
|
23
23
|
@id = get_id(test_case)
|
24
24
|
raise 'No id found' unless @id
|
25
25
|
send_steps(test_case,@id)
|
26
|
+
if ENV['UPDATE_SOURCE']
|
27
|
+
update_source_file(test_case,@id) unless test_case.source.any?{|h| h.is_a?(Cucumber::Core::Ast::ScenarioOutline)}
|
28
|
+
end
|
26
29
|
if ENV['TESTRUN']
|
27
30
|
send_result(test_case,result,@id,ENV['TESTRUN'].to_i)
|
28
31
|
end
|
@@ -55,31 +58,38 @@ module Cukerail
|
|
55
58
|
|
56
59
|
def get_id(test_case)
|
57
60
|
# ap test_case.methods - Object.methods
|
58
|
-
tagged_id = test_case.tags.
|
59
|
-
|
60
|
-
|
61
|
-
suite_id = /\d+/.match(tags.select{|tag| tag.name =~/suite/}.first.name)[0]
|
62
|
-
title = extract_title(test_case)
|
63
|
-
found_case = testrail_api_client.send_get("get_cases/#{project_id}&suite_id=#{suite_id}").select{|c| c['title'] == title}.first
|
64
|
-
if found_case
|
65
|
-
result= found_case['id']
|
61
|
+
tagged_id = test_case.tags.detect{|tag| tag.name =~/testcase/}
|
62
|
+
if tagged_id
|
63
|
+
result = /testcase_(\d+)/.match(tagged_id.name)[1]
|
66
64
|
else
|
67
|
-
|
68
|
-
|
65
|
+
tags = all_tags(test_case)
|
66
|
+
project_id = /\d+/.match(tags.select{|tag| tag.name =~/project/}.first.name)[0]
|
67
|
+
suite_id = /\d+/.match(tags.select{|tag| tag.name =~/suite/}.first.name)[0]
|
68
|
+
title = extract_title(test_case)
|
69
|
+
found_case = testrail_api_client.send_get("get_cases/#{project_id}&suite_id=#{suite_id}").select{|c| c['title'] == title}.first
|
70
|
+
if found_case
|
71
|
+
result= found_case['id']
|
72
|
+
else
|
73
|
+
sub_section_id = /\d+/.match(tags.select{|tag| tag.name =~/sub_section/}.first.name)[0]
|
74
|
+
result = create_new_case(project_id,suite_id,sub_section_id,test_case)['id']
|
75
|
+
end
|
69
76
|
end
|
70
77
|
return result
|
71
78
|
end
|
72
79
|
|
73
80
|
def update_source_file(scenario, external_reference)
|
74
81
|
#this could be done on one line with sed. But the format is different on Mac OS and GNU Linux version and it definitely won't work on a Windows machine
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
lines
|
82
|
+
# byebug
|
83
|
+
path = scenario.location.file
|
84
|
+
# ap path
|
85
|
+
lines = IO.readlines(path)
|
86
|
+
lines[scenario.location.line-2].gsub!(/ @testcase_\d*/," @testcase_#{external_reference}")
|
87
|
+
lines[scenario.location.line-2].gsub!(/\n/," @testcase_#{external_reference}") unless lines[scenario.location.line-2] =~ /testcase/
|
79
88
|
temp_file = Tempfile.new('foo')
|
80
89
|
begin
|
81
90
|
File.open(path, 'r') do |file|
|
82
91
|
lines.each do |line|
|
92
|
+
# puts line
|
83
93
|
temp_file.puts line
|
84
94
|
end
|
85
95
|
end
|
@@ -98,7 +108,7 @@ module Cukerail
|
|
98
108
|
str = g_step.send(:keyword)+g_step.send(:name)
|
99
109
|
str += g_step.multiline_arg.raw.map{|l|"\n| #{l.join(' | ')} |"}.join if g_step.multiline_arg.data_table?
|
100
110
|
str
|
101
|
-
|
111
|
+
end.join("\n")
|
102
112
|
is_manual = test_case.tags.any?{|tag| tag.name =~/manual/}
|
103
113
|
data = {'title'=>extract_title(test_case),
|
104
114
|
'type_id'=>(is_manual ? 7 : 1 ),
|
data/lib/json_sender.rb
CHANGED
@@ -75,16 +75,18 @@ module Cukerail
|
|
75
75
|
}
|
76
76
|
end
|
77
77
|
|
78
|
-
def defects(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
78
|
+
def defects(scenario)
|
79
|
+
if scenario['tags']
|
80
|
+
tags= [scenario['tags']].flatten.compact
|
81
|
+
tags.select{|tag| tag['name'] =~/(?:jira|defect)_/}.map{|ticket| /(?:jira|defect)_(\w+-\d+)$/.match(ticket['name'])[1]}.uniq.join(",")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def refs(scenario)
|
86
|
+
if scenario['tags']
|
87
|
+
tags= [scenario['tags']].flatten.compact
|
88
|
+
tags.select{|tag| tag['name'] =~/(?:jira|ref)_/}.map{|ticket| /(?:jira|ref)_(\w+-\d+)$/.match(ticket['name'])[1]}.uniq.join(",")
|
89
|
+
end
|
88
90
|
end
|
89
91
|
|
90
92
|
def send_result(scenario,id,run_id)
|
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.
|
4
|
+
version: 0.5.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: 2016-
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|