@@ -7,15 +7,30 @@ module AssertThatBDD
7
7
class Features
8
8
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 )
9
9
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?
12
12
resource = RestClient ::Resource . new ( url , :user => accessKey , :password => secretKey , :content_type => 'application/zip' )
13
13
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" )
15
30
rescue => e
16
31
17
32
if e . respond_to? ( 'response' ) then
18
- if e . response . respond_to? ( 'code' ) then
33
+ if e . response . respond_to? ( 'code' ) then
19
34
case e . response . code
20
35
when 401
21
36
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
25
40
puts '*** ERROR: Jira server error (500)'
26
41
end
27
42
end
28
- else
43
+ else
29
44
puts '*** ERROR: Failed download features: ' + e . message
30
45
end
31
46
return
32
47
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
42
48
end
43
- puts "*** INFO: #{ features_count } features downloaded"
44
- File . delete ( "#{ outputFolder } /features.zip" )
49
+ end
45
50
end
46
51
end
47
52
0 commit comments