assertthat-bdd 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80e414c9443556d6ca0bf2495db50c4ace281c8e8495a1b55658e2dbfe629000
4
+ data.tar.gz: 14c721b228cc16855b5248b69689d87f777573cfe5a9f7de83324b509b24efc0
5
+ SHA512:
6
+ metadata.gz: f64dfb3906476c99e23000091ce7fe0e7b784bece1d07e0c37537389bfac0777e818b52cf063316be3dc6d4a4213fb4fbb9c899e3a890105e2089c3de5b24566
7
+ data.tar.gz: 564c3914995361bd92ba4e05d1ef67f943f4bb680b2a8e10208b7f96716508e961e78f74fb2d387189d33d618b43227684e71eb6a8bd5b284f3b06303908e1b6
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'assertthat-bdd'
3
+ require 'optparse'
4
+
5
+ VERSION = '1.0.0'
6
+
7
+ options = {}
8
+ OptionParser.new do |opt|
9
+ opt.on('-a','--accessKey ACCESS_KEY', 'Access key same as env variable ASSERTTHAT_ACCESS_KEY') { |o| options[:accessKey] = o }
10
+ opt.on('-s','--secretKey SECRET_KEY', 'Secret key same as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
11
+ opt.on('-p','--projectId PROJECT_ID', 'Jira project id') { |o| options[:projectId] = o }
12
+ opt.on('-o','--outputFolder OUTPUT_FOLDER', 'Featured output folder - default ./features') { |o| options[:outputFolder] = o }
13
+ opt.on('-m','--mode MODE', 'Mode one of automated,manual,both - deafult automated') { |o| options[:mode] = o }
14
+ opt.on('-j','--jql JQL_FILTER', 'Jql issues filter') { |o| options[:jql] = o }
15
+ opt.on('-x','--proxy PROXY_URL', 'proxy url to connect to Jira') { |o| options[:proxy] = o }
16
+ opt.on_tail('-h', '--help', 'Show help') do
17
+ puts opt
18
+ exit
19
+ end
20
+ opt.on_tail('-v','--version', 'Show version') do
21
+ puts VERSION
22
+ exit
23
+ end
24
+ end.parse!
25
+
26
+ raise OptionParser::MissingArgument, "'projectId' option is not specified" if options[:projectId].nil?
27
+
28
+ AssertThatBDD::Features.download(options)
29
+
30
+
31
+
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require 'assertthat-bdd'
3
+ require 'optparse'
4
+
5
+ VERSION = '0.0.1'
6
+
7
+ options = {}
8
+ OptionParser.new do |opt|
9
+ opt.on('-a','--accessKey ACCESS_KEY', 'Access key same as env variable ASSERTTHAT_ACCESS_KEY') { |o| options[:accessKey] = o }
10
+ opt.on('-s','--secretKey SECRET_KEY', 'Secret key same as env variable ASSERTTHAT_SECRET_KEY') { |o| options[:secretKey] = o }
11
+ opt.on('-p', '--projectId PROJECT_ID', 'Jira project id') { |o| options[:projectId] = o }
12
+ opt.on('-n','--runName RUN_NAME', 'The name of the run - default \'Test run dd MMM yyyy HH:mm:ss\'') { |o| options[:runName] = o }
13
+ opt.on('-f','--jsonReportFolder JSON_FOLDER_PATH', 'Json report folder - default ./reports') { |o| options[:mode] = o }
14
+ opt.on('-i','--jsonReportIncludePattern INCLUDE_REGEX', 'Regex to search for cucumber reports - default .*.json') { |o| options[:jql] = o }
15
+ opt.on('-x','--proxy PROXY_URL', 'proxy url to connect to Jira') { |o| options[:proxy] = o }
16
+ opt.on_tail('-h', '--help', 'Show help') do
17
+ puts opt
18
+ exit
19
+ end
20
+ opt.on_tail('-v','--version', 'Show version') do
21
+ puts VERSION
22
+ exit
23
+ end
24
+ end.parse!
25
+
26
+ raise OptionParser::MissingArgument, "'projectId' option is not specified" if options[:projectId].nil?
27
+
28
+ AssertThatBDD::Report.upload(options)
29
+
30
+
@@ -0,0 +1,87 @@
1
+ require 'rest-client'
2
+ require 'zip'
3
+ require 'find'
4
+ require 'json'
5
+
6
+ module AssertThatBDD
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: '')
9
+ RestClient.proxy = proxy unless proxy.nil?
10
+ url = 'https://bdd.assertthat.com/rest/api/1/project/'+ projectId +'/features'
11
+ resource = RestClient::Resource.new(url, :user => accessKey, :password => secretKey, :content_type => 'application/zip')
12
+ begin
13
+ contents = resource.get(:accept => 'application/zip', params: {mode: mode, jql: jql})
14
+ rescue => e
15
+
16
+ if e.respond_to?('response') then
17
+ if e.response.respond_to?('code') then
18
+ case e.response.code
19
+ when 401
20
+ puts '[ERROR] Unauthorized error (401). Supplied secretKey/accessKey is invalid'
21
+ when 400
22
+ puts '[ERROR] ' + e.response
23
+ when 500
24
+ puts '[ERROR] Jira server error (500)'
25
+ end
26
+ end
27
+ else
28
+ puts '[ERROR] Failed download features: ' + e.message
29
+ end
30
+ return
31
+ end
32
+ Dir.mkdir("#{outputFolder}") unless File.exists?("#{outputFolder}")
33
+ File.open("#{outputFolder}/features.zip", 'wb') {|f| f.write(contents) }
34
+ Zip::File.open("#{outputFolder}/features.zip") do |zip_file|
35
+ zip_file.each do |entry|
36
+ File.delete("#{outputFolder}#{entry.name}") if File.exists?("#{outputFolder}#{entry.name}")
37
+ entry.extract("#{outputFolder}#{entry.name}")
38
+ end
39
+ end
40
+ File.delete("#{outputFolder}/features.zip")
41
+ end
42
+ end
43
+
44
+ class Report
45
+ 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' )
46
+ url = "https://bdd.assertthat.com/rest/api/1/project/" + projectId + "/report"
47
+ files = Find.find(jsonReportFolder).grep(/#{jsonReportIncludePattern}/)
48
+ runId = -1
49
+ files.each do |f|
50
+ request = RestClient::Request.new(
51
+ :method => :post,
52
+ :url => url,
53
+ :user => accessKey,
54
+ :password => secretKey,
55
+ :payload => {
56
+ :multipart => true,
57
+ :file => File.new(f, 'rb')
58
+ },
59
+ :headers => { :params =>{:runName => runName, :runId=> runId}}
60
+ )
61
+ begin
62
+ response = request.execute
63
+ rescue => e
64
+ if e.respond_to?('response') then
65
+ if e.response.respond_to?('code') then
66
+ case e.response.code
67
+ when 401
68
+ puts '[ERROR] Unauthorized error (401). Supplied secretKey/accessKey is invalid'
69
+ when 500
70
+ puts '[ERROR] Jira server error (500)'
71
+ end
72
+ end
73
+ else
74
+ puts '[ERROR] Failed to submit report: ' + e.message
75
+ end
76
+ return
77
+ end
78
+ resposne_json = JSON.parse(response)
79
+ if resposne_json['result'] == 'success'
80
+ runId = resposne_json['runId']
81
+ else
82
+ puts '[ERROR] Failed to submit report: ' + resposne_json['message']
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assertthat-bdd
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Glib Briia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: rubyzip
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 1.0.0
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.0.0
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.0'
53
+ description:
54
+ email: glib.briia@assertthat.com
55
+ executables:
56
+ - assertthat-bdd-features
57
+ - assertthat-bdd-report
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - bin/assertthat-bdd-features
62
+ - bin/assertthat-bdd-report
63
+ - lib/assertthat-bdd.rb
64
+ homepage: https://rubygems.org/gems/assertthat-bdd
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.7.8
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: AssertThat bdd integration for Ruby
88
+ test_files: []