assertthat-bdd 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/assertthat-bdd-features +11 -10
- data/bin/assertthat-bdd-report +11 -9
- data/lib/assertthat-bdd.rb +99 -80
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14aef6816defd3bd8214ee75701f891cd1a14598e25e47216a796390e0cccf31
|
4
|
+
data.tar.gz: 4a51704bdaa2e34e82ed229bbcd3a8780cfe99acf5d8f6149b4654872a526a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5d6cfab11eb5880d617d49b15edf74532fd335d026e4e80c1db3827d67b3b88cb9852f521313df0c3b5f0d09c80652d245146bb4638d7d3646628e8e485dbc1
|
7
|
+
data.tar.gz: ac695a7034b143bb5d08e9910b09bd22be767b791f7820e23fa2b55b9469dd848d561a01a33a2625bfdd8a128e0bf761557a43c9a42776df8bbae78fa00eb05e
|
data/bin/assertthat-bdd-features
CHANGED
@@ -2,19 +2,20 @@
|
|
2
2
|
require 'assertthat-bdd'
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
-
VERSION = '1.6.
|
5
|
+
VERSION = '1.6.4'
|
6
6
|
|
7
7
|
options = {}
|
8
8
|
OptionParser.new do |opt|
|
9
|
-
opt.on('
|
10
|
-
opt.on('
|
11
|
-
opt.on('
|
12
|
-
opt.on('
|
13
|
-
opt.on('
|
14
|
-
opt.on('
|
15
|
-
opt.on('
|
16
|
-
opt.on('
|
17
|
-
opt.on('
|
9
|
+
opt.on('--accessKey ACCESS_KEY', 'Access key same as env variable ASSERTTHAT_ACCESS_KEY') { |o| options[:accessKey] = o }
|
10
|
+
opt.on('--secretKey SECRET_KEY', 'Secret key same as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
|
11
|
+
opt.on('--token TOKEN', 'Jira API token as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
|
12
|
+
opt.on('--jiraServerUrl SERVER_URL', 'Jira server URL') { |o| options[:jiraServerUrl] = o }
|
13
|
+
opt.on('--projectId PROJECT_ID', 'Jira project id') { |o| options[:projectId] = o }
|
14
|
+
opt.on('--outputFolder OUTPUT_FOLDER', 'Featured output folder - default ./features') { |o| options[:outputFolder] = o }
|
15
|
+
opt.on('--mode MODE', 'Mode one of automated,manual,both - deafult automated') { |o| options[:mode] = o }
|
16
|
+
opt.on('--tags <tag-expression>', 'Cucucmber tag expression for scenarios filtering') { |o| options[:tags] = o }
|
17
|
+
opt.on('--jql JQL_FILTER', 'Jql issues filter') { |o| options[:jql] = o }
|
18
|
+
opt.on('--proxy PROXY_URL', 'proxy url to connect to Jira') { |o| options[:proxy] = o }
|
18
19
|
opt.on_tail('-h', '--help', 'Show help') do
|
19
20
|
puts opt
|
20
21
|
exit
|
data/bin/assertthat-bdd-report
CHANGED
@@ -2,18 +2,20 @@
|
|
2
2
|
require 'assertthat-bdd'
|
3
3
|
require 'optparse'
|
4
4
|
|
5
|
-
VERSION = '1.6.
|
5
|
+
VERSION = '1.6.4'
|
6
6
|
|
7
7
|
options = {}
|
8
8
|
OptionParser.new do |opt|
|
9
|
-
opt.on('
|
10
|
-
opt.on('
|
11
|
-
opt.on('
|
12
|
-
opt.on('
|
13
|
-
opt.on('
|
14
|
-
opt.on('
|
15
|
-
opt.on('
|
16
|
-
opt.on('
|
9
|
+
opt.on('--accessKey ACCESS_KEY', 'Access key same as env variable ASSERTTHAT_ACCESS_KEY') { |o| options[:accessKey] = o }
|
10
|
+
opt.on('--secretKey SECRET_KEY', 'Secret key same as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
|
11
|
+
opt.on('--token TOKEN', 'Jira API token as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
|
12
|
+
opt.on('--jiraServerUrl SERVER_URL', 'Jira server URL') { |o| options[:jiraServerUrl] = o }
|
13
|
+
opt.on('--projectId PROJECT_ID', 'Jira project id') { |o| options[:projectId] = o }
|
14
|
+
opt.on('--runName RUN_NAME', 'The name of the run - default \'Test run dd MMM yyyy HH:mm:ss\'') { |o| options[:runName] = o }
|
15
|
+
opt.on('--jsonReportFolder JSON_FOLDER_PATH', 'Json report folder - default ./reports') { |o| options[:mode] = o }
|
16
|
+
opt.on('--jsonReportIncludePattern INCLUDE_REGEX', 'Regex to search for cucumber reports - default .*.json') { |o| options[:jql] = o }
|
17
|
+
opt.on('--jql JQL_FILTER', 'Jql issues filter to update with results') { |o| options[:jql] = o }
|
18
|
+
opt.on('--proxy PROXY_URL', 'proxy url to connect to Jira') { |o| options[:proxy] = o }
|
17
19
|
opt.on_tail('-h', '--help', 'Show help') do
|
18
20
|
puts opt
|
19
21
|
exit
|
data/lib/assertthat-bdd.rb
CHANGED
@@ -5,87 +5,106 @@ require 'json'
|
|
5
5
|
|
6
6
|
module AssertThatBDD
|
7
7
|
class Features
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
8
|
+
def self.download(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], token: ENV['ASSERTTHAT_TOKEN'], projectId: nil, outputFolder: './features/', proxy: nil, mode: 'automated', jql: '', tags: '', jiraServerUrl: nil)
|
9
|
+
RestClient.proxy = proxy unless proxy.nil?
|
10
|
+
url = ['https://bdd.assertthat.app/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
|
+
|
13
|
+
headers = { accept: 'application/zip', params: { mode: mode, jql: jql, tags: tags } }
|
14
|
+
if token
|
15
|
+
headers[:authorization] = "Bearer #{token}"
|
16
|
+
resource = RestClient::Resource.new(url, headers: headers)
|
17
|
+
else
|
18
|
+
resource = RestClient::Resource.new(url, user: accessKey, password: secretKey, headers: headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
resource.get do |response, request, result|
|
22
|
+
case response.code
|
23
|
+
when 401
|
24
|
+
puts '*** ERROR: Unauthorized error (401). Supplied secretKey/accessKey is invalid'
|
25
|
+
return
|
26
|
+
when 400
|
27
|
+
puts '*** ERROR: ' + e.response
|
28
|
+
return
|
29
|
+
when 500
|
30
|
+
puts '*** ERROR: Jira server error (500)'
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
Dir.mkdir(outputFolder) unless File.exists?(outputFolder)
|
35
|
+
File.open("#{outputFolder}/features.zip", 'wb') { |f| f.write(response) }
|
36
|
+
features_count = 0
|
37
|
+
Zip::File.open("#{outputFolder}/features.zip") do |zip_file|
|
38
|
+
zip_file.each do |entry|
|
39
|
+
features_count += 1
|
40
|
+
File.delete("#{outputFolder}#{entry.name}") if File.exists?("#{outputFolder}#{entry.name}")
|
41
|
+
entry.extract("#{outputFolder}#{entry.name}")
|
42
|
+
end
|
43
|
+
if response.headers.key?(:features_count) && response.headers.key?(:scenarios_count)
|
44
|
+
puts "*** INFO: #{response.headers[:features_count]} features downloaded with #{response.headers[:scenarios_count]} scenarios"
|
45
|
+
else
|
46
|
+
puts "*** INFO: #{features_count} features downloaded"
|
47
|
+
end
|
48
|
+
File.delete("#{outputFolder}/features.zip")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
43
52
|
end
|
44
|
-
|
53
|
+
|
45
54
|
class Report
|
46
|
-
def self.upload(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], projectId: nil, runName: 'Test run '+Time.now.strftime("%d %b %Y %H:%M:%S"), jsonReportFolder: './reports', jsonReportIncludePattern: '.*.json', jiraServerUrl: nil
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
55
|
+
def self.upload(accessKey: ENV['ASSERTTHAT_ACCESS_KEY'], secretKey: ENV['ASSERTTHAT_ACCESS_KEY'], token: ENV['ASSERTTHAT_TOKEN'], projectId: nil, runName: 'Test run ' + Time.now.strftime("%d %b %Y %H:%M:%S"), jsonReportFolder: './reports', jsonReportIncludePattern: '.*.json', jql: nil, jiraServerUrl: nil)
|
56
|
+
url = "https://bdd.assertthat.app/rest/api/1/project/#{projectId}/report"
|
57
|
+
url = "#{jiraServerUrl}/rest/assertthat/latest/project/#{projectId}/client/report" unless jiraServerUrl.nil?
|
58
|
+
|
59
|
+
headers = { params: { runName: runName, jql: jql } }
|
60
|
+
headers[:authorization] = "Bearer #{token}" if token
|
61
|
+
|
62
|
+
files = Find.find(jsonReportFolder).grep(/#{jsonReportIncludePattern}/)
|
63
|
+
puts "*** INFO: #{files.count} files found matching pattern #{jsonReportIncludePattern}:"
|
64
|
+
puts "*** INFO: #{files}"
|
65
|
+
runId = -1
|
66
|
+
|
67
|
+
files.each do |f|
|
68
|
+
payload = { multipart: true, file: File.new(f, 'rb') }
|
69
|
+
|
70
|
+
if token
|
71
|
+
request = RestClient::Request.new(
|
72
|
+
method: :post,
|
73
|
+
url: url,
|
74
|
+
payload: payload,
|
75
|
+
headers: headers
|
76
|
+
)
|
77
|
+
else
|
78
|
+
request = RestClient::Request.new(
|
79
|
+
method: :post,
|
80
|
+
url: url,
|
81
|
+
user: accessKey,
|
82
|
+
password: secretKey,
|
83
|
+
payload: payload,
|
84
|
+
headers: headers
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
begin
|
89
|
+
response = request.execute
|
90
|
+
response_json = JSON.parse(response)
|
91
|
+
if response_json['result'] == 'success'
|
92
|
+
runId = response_json['runId']
|
93
|
+
else
|
94
|
+
puts "*** ERROR: Failed to submit json #{f}: " + response_json['message']
|
95
|
+
end
|
96
|
+
rescue RestClient::ExceptionWithResponse => e
|
97
|
+
case e.http_code
|
98
|
+
when 401
|
99
|
+
puts '*** ERROR: Unauthorized error (401). Supplied secretKey/accessKey is invalid'
|
100
|
+
when 500
|
101
|
+
puts '*** ERROR: Jira server error (500)'
|
102
|
+
else
|
103
|
+
puts "*** ERROR: Failed to submit json #{f}: " + e.message
|
104
|
+
end
|
105
|
+
return
|
106
|
+
end
|
107
|
+
end
|
89
108
|
end
|
90
|
-
end
|
109
|
+
end
|
91
110
|
end
|