Skip to content

Commit 4caf485

Browse files
committed
Add scenario count
1 parent 403cb44 commit 4caf485

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

assertthat-bdd.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = %q{assertthat-bdd}
3-
s.version = "1.4.0"
3+
s.version = "1.5.0"
44
s.date = %q{2020-05-08}
55
s.summary = %q{AssertThat bdd integration for Ruby}
66
s.authors = ["Glib Briia"]

lib/assertthat-bdd.rb

+21-16
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,30 @@ module AssertThatBDD
77
class Features
88
def self.download(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], projectId: nil, outputFolder: './features/', proxy: nil, mode: 'automated', jql: '', tags: '', jiraServerUrl: nil)
99
RestClient.proxy = proxy unless proxy.nil?
10-
url = 'https://bdd.assertthat.app/rest/api/1/project/'+ projectId +'/features'
11-
url = jiraServerUrl+"/rest/assertthat/latest/project/"+projectId+"/client/features" unless jiraServerUrl.nil?
10+
url = ['https://heavy-bat-23.loca.lt/rest/api/1/project/', projectId, '/features'].map(&:to_s).join('')
11+
url = [jiraServerUrl,"/rest/assertthat/latest/project/",projectId,"/client/features"].map(&:to_s).join('') unless jiraServerUrl.nil?
1212
resource = RestClient::Resource.new(url, :user => accessKey, :password => secretKey, :content_type => 'application/zip')
1313
begin
14-
contents = resource.get(:accept => 'application/zip', params: {mode: mode, jql: jql, tags: tags})
14+
resource.get(:accept => 'application/zip', params: {mode: mode, jql: jql, tags: tags}) do |response, request, result|
15+
Dir.mkdir("#{outputFolder}") unless File.exists?("#{outputFolder}")
16+
File.open("#{outputFolder}/features.zip", 'wb') {|f| f.write(response) }
17+
features_count = 0
18+
Zip::File.open("#{outputFolder}/features.zip") do |zip_file|
19+
zip_file.each do |entry|
20+
features_count = features_count + 1
21+
File.delete("#{outputFolder}#{entry.name}") if File.exists?("#{outputFolder}#{entry.name}")
22+
entry.extract("#{outputFolder}#{entry.name}")
23+
end
24+
if response.headers.member?('features_count'.to_sym) and response.headers.member?('scenarios_count'.to_sym) then
25+
puts "*** INFO: #{response.headers['features_count'.to_sym]} features downloaded with #{response.headers['scenarios_count'.to_sym]} scenarios"
26+
else
27+
puts "*** INFO: #{features_count} features downloaded"
28+
end
29+
File.delete("#{outputFolder}/features.zip")
1530
rescue => e
1631

1732
if e.respond_to?('response') then
18-
if e.response.respond_to?('code') then
33+
if e.response.respond_to?('code') then
1934
case e.response.code
2035
when 401
2136
puts '*** ERROR: Unauthorized error (401). Supplied secretKey/accessKey is invalid'
@@ -25,23 +40,13 @@ def self.download(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSER
2540
puts '*** ERROR: Jira server error (500)'
2641
end
2742
end
28-
else
43+
else
2944
puts '*** ERROR: Failed download features: ' + e.message
3045
end
3146
return
3247
end
33-
Dir.mkdir("#{outputFolder}") unless File.exists?("#{outputFolder}")
34-
File.open("#{outputFolder}/features.zip", 'wb') {|f| f.write(contents) }
35-
features_count = 0
36-
Zip::File.open("#{outputFolder}/features.zip") do |zip_file|
37-
zip_file.each do |entry|
38-
features_count = features_count + 1
39-
File.delete("#{outputFolder}#{entry.name}") if File.exists?("#{outputFolder}#{entry.name}")
40-
entry.extract("#{outputFolder}#{entry.name}")
41-
end
4248
end
43-
puts "*** INFO: #{features_count} features downloaded"
44-
File.delete("#{outputFolder}/features.zip")
49+
end
4550
end
4651
end
4752

0 commit comments

Comments
 (0)