cukerail 0.3.7 → 0.4.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: 570992f82426d84b39ac68b25187b09e65f2e0f2
4
- data.tar.gz: 90f921ed50dfc2968fc7b474a7f711044eb17e5f
3
+ metadata.gz: ecd3ab994dc1ef75c983e2bb539856039eb59e2c
4
+ data.tar.gz: a912228bc1cc3844acfbd0471b2479c6aca829aa
5
5
  SHA512:
6
- metadata.gz: 12a645887f388138912dc2ffc628790ff559eaf736d68e37d3d1d9247536e6e914522142213c472a480a201071458e1e63e4a72be523a87521307b7bb74c65b3
7
- data.tar.gz: 696f93b14f1f5d46bbffed0dfc239ba4990b51207947985829079741dfc02640d4c14e7ba7affde4c9dc3b514779f8c2cd81089db425ef3ec4d02dd36b552a7b
6
+ metadata.gz: f126d6ef8519d0c6364619d3f10003f77e4af5d590fff30db4b0df6d24679937811beb11ed1911e0245fae32f45fc5d394bf10ae711a14dc905cf441bd998384
7
+ data.tar.gz: 1c923b752e530f1c816639dfe964e79ff4fc7fb5e2d3fb57a6c112c7b06f15ac5fae8501fbc9bba766f0217564c02a1b3e33fc660c02cb632ca439c9d9de0e75
data/cukerail.gemspec CHANGED
@@ -3,6 +3,7 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'cukerail/version'
5
5
  require "cukerail/testrail"
6
+ # require "cucumber_extensions/formatters/json/builder"
6
7
 
7
8
  Gem::Specification.new do |spec|
8
9
  spec.name = "cukerail"
@@ -19,6 +20,8 @@ Gem::Specification.new do |spec|
19
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
21
  spec.require_paths = ["lib"]
21
22
 
23
+ spec.add_runtime_dependency "cucumber", "~> 2.3.2"
24
+
22
25
  spec.add_development_dependency "bundler", "~> 1.6"
23
26
  spec.add_development_dependency "rake","~>10.4"
24
27
  spec.add_development_dependency "rspec","~>3.2"
@@ -0,0 +1,35 @@
1
+ module Cukerail
2
+ require 'cucumber/formatter/json'
3
+ class Json < Cucumber::Formatter::Json
4
+ class Cucumber::Formatter::Json::Builder
5
+ def scenario_outline(scenario)
6
+ # puts 'in scenario outline'
7
+ @test_case_hash = {
8
+ id: create_id(scenario) + ';' + (@example_id.gsub(' ','').gsub(',',';')),
9
+ keyword: scenario.keyword,
10
+ name: scenario.name + ' ' + @example_id,
11
+ description: scenario.description,
12
+ line: @row.location.line,
13
+ type: 'scenario'
14
+ }
15
+ tags = []
16
+ tags += create_tags_array(scenario.tags) unless scenario.tags.empty?
17
+ tags += @examples_table_tags if @examples_table_tags
18
+ @test_case_hash[:tags] = tags unless tags.empty?
19
+ comments = []
20
+ comments += Formatter.create_comments_array(scenario.comments) unless scenario.comments.empty?
21
+ comments += @examples_table_comments if @examples_table_comments
22
+ comments += @row_comments if @row_comments
23
+ @test_case_hash[:comments] = comments unless comments.empty?
24
+ end
25
+
26
+ def examples_table(examples_table)
27
+ # puts 'in examples table'
28
+ # We want the row data to be used in making the full scenario name
29
+ @example_id = @row.send(:data).map{|k,v| "#{k}=#{v}"}.join(", ")
30
+ @examples_table_tags = create_tags_array(examples_table.tags) unless examples_table.tags.empty?
31
+ @examples_table_comments = Formatter.create_comments_array(examples_table.comments) unless examples_table.comments.empty?
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Cukerail
2
- VERSION = "0.3.7"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/cukerail.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require "cukerail/version"
2
2
  require "cukerail/testrail"
3
+ # require_relative "cucumber_extensions/formatters/json/builder"
4
+ # puts 'load extensions'
5
+ # puts (Cucumber::Formatter.name)
6
+ # Cucumber::Formatter::Json::Builder.include CucumberExtensions::Formatter::Json::Builder
3
7
  module Cukerail
4
8
  class Sender
5
9
  attr_reader :testrail_api_client,:failed_step
@@ -102,7 +106,7 @@ module Cukerail
102
106
  data = {'title'=>extract_title(test_case),
103
107
  'type_id'=>(is_manual ? 7 : 1 ),
104
108
  'custom_steps'=>steps_as_string,
105
- 'refs'=>defects(test_case)
109
+ 'refs'=>refs(test_case)
106
110
  }
107
111
  testrail_api_client.send_post("update_case/#{id}",data)
108
112
  end
@@ -113,7 +117,7 @@ module Cukerail
113
117
  data = {'title'=>extract_title(test_case),
114
118
  'type_id'=>(is_manual ? 7 : 1 ),
115
119
  'custom_steps'=>steps_as_string,
116
- 'refs'=>defects(test_case)
120
+ 'refs'=>refs(test_case)
117
121
  }
118
122
  testrail_api_client.send_post("add_case/#{sub_section_id || suite_id}", data)
119
123
  end
@@ -186,7 +190,11 @@ module Cukerail
186
190
  end
187
191
 
188
192
  def defects(test_case)
189
- all_tags(test_case).select{|tag| tag.name =~/jira_/}.map{|ticket| /jira_(\w+-\d+)$/.match(ticket.name)[1]}.uniq.join(",")
193
+ all_tags(test_case).select{|tag| tag.name =~/(?:jira|defect)_/}.map{|ticket| /(?:jira|defect)_(\w+-\d+)$/.match(ticket.name)[1]}.uniq.join(",")
194
+ end
195
+
196
+ def refs(test_case)
197
+ all_tags(test_case).select{|tag| tag.name =~/(?:jira|ref)_/}.map{|ticket| /(?:jira|ref)_(\w+-\d+)$/.match(ticket.name)[1]}.uniq.join(",")
190
198
  end
191
199
 
192
200
  def update_run(run_id,case_ids)
data/lib/json_sender.rb CHANGED
@@ -71,13 +71,19 @@ module Cukerail
71
71
  data = {'title'=>get_name(scenario),
72
72
  'type_id'=>(is_manual ? 7 : 1 ),
73
73
  'custom_steps'=>steps,
74
- 'refs'=>defects(scenario)
74
+ 'refs'=>refs(scenario)
75
75
  }
76
76
  end
77
77
 
78
- def defects(scenario)
78
+ def defects(test_case)
79
79
  if scenario['tags']
80
- scenario['tags'].select{|t| t['name'] =~/@jira_/}.map{|t| /jira_(\w+-\d+)/.match(t['name'])[1]}.join(' ')
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(",")
81
87
  end
82
88
  end
83
89
 
@@ -114,7 +120,7 @@ module Cukerail
114
120
  tries -= 1
115
121
  add_case_to_test_run(id,run_id)
116
122
  if tries > 0
117
- retry
123
+ retry
118
124
  else
119
125
  puts "#{e.message} testrun=#{run_id} test case id=#{id}"
120
126
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukerail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.4.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-02-16 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +110,7 @@ files:
96
110
  - Rakefile
97
111
  - cukerail.gemspec
98
112
  - lib/cukerail.rb
113
+ - lib/cukerail/json.rb
99
114
  - lib/cukerail/testrail.rb
100
115
  - lib/cukerail/version.rb
101
116
  - lib/json_sender.rb