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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75e6fc40ef21987c38033b470c41f5035179c223
4
- data.tar.gz: 84eb59245d2ac558cf377835fb93b9744fd23e3a
3
+ metadata.gz: fcb1e0a9b7c38f50b8804df39b29e0157077591c
4
+ data.tar.gz: fe105c55011ce966dd6105019bce6d0b9d33824b
5
5
  SHA512:
6
- metadata.gz: 319fe786247626271bff9ff21a54984cd3e1ebd0f3d808a25c2c55ec8ca3f0d001410a0b5f27f7a0dbd11d407cbc6644f662758ef06d0178a6395d99e578b194
7
- data.tar.gz: a13e62c61a87df9cdbc72af66142255bfecc6df5c26a03b88db1cba48ee2888edbf4c83c7e5c6f6c2642892edd442f05380f240b8c61324500a9f690c9787f37
6
+ metadata.gz: 0482e90c13c1e1ac3403c4b531a48a59a5863b15b6a7ed007b6676a3092f793bf991f6bb3310156a75a4d22f00d6ae40fd65ed138f138adde1ffd6b077445268
7
+ data.tar.gz: bdfd582e2d35f50decab8e2dd35e948a376b6f36af968934741bc43c2fcb23532408d387d6c74b637eaf0c98519b40e2fbf1bb9181a9f8059ba4e8e990bf8b55
@@ -1,3 +1,3 @@
1
1
  module Cukerail
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
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.select{|tag| tag.name =~/testcase/}.first
59
- tags = all_tags(test_case)
60
- project_id = /\d+/.match(tags.select{|tag| tag.name =~/project/}.first.name)[0]
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
- sub_section_id = /\d+/.match(tags.select{|tag| tag.name =~/sub_section/}.first.name)[0]
68
- result = create_new_case(project_id,suite_id,sub_section_id,test_case)['id']
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
- path = scenario.file
76
- lines = IO.readlines(scenario.file)
77
- lines[scenario.line-2].gsub!(/ @testcase_\d*/," @testcase_#{external_reference}")
78
- lines[scenario.line-2].gsub!(/\n/," @testcase_#{external_reference}") unless lines[scenario.line-2] =~ /testcase/
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
- end.join("\n")
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(test_case)
79
- if scenario['tags']
80
- all_tags(test_case).select{|tag| tag['name'] =~/(?:jira|defect)_/}.map{|ticket| /(?:jira|defect)_(\w+-\d+)$/.match(ticket['name'])[1]}.uniq.join(",")
81
- end
82
- end
83
-
84
- def refs(test_case)
85
- if scenario['tags']
86
- all_tags(test_case).select{|tag| tag['name'] =~/(?:jira|ref)_/}.map{|ticket| /(?:jira|ref)_(\w+-\d+)$/.match(ticket['name'])[1]}.uniq.join(",")
87
- end
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.4
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-03-14 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber