cucumber-calliope_importer 0.1.6 → 0.1.7

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: 2c9ba7867e62f729c04d2f9306d4366db56dba7f
4
- data.tar.gz: 280855a416fbe826b05eb891b65de35233f72cd1
3
+ metadata.gz: fd361fe9f09ef71cc0630d7913eff575f098348c
4
+ data.tar.gz: 654e3da9f84e2876465ffdd19b43583d371366b9
5
5
  SHA512:
6
- metadata.gz: 5abb9091c55d1a69627fa81082a3c1d87970d05f4ea234d2ae0737cb916e1f0413bca6f5f742ae0e8bb884e28db9efdc7afd1887004cd960179423548147a7d5
7
- data.tar.gz: 98b0496f196d1a3a504bee78ae1ce234c97140d242c52af29b48149ecde2387642d8682e4ef9c70ac9327aae190b3eb73bee8e43252d8ede7bd1c0bc9d79bcc1
6
+ metadata.gz: c2bf48d47c0c5f4aaba924fb7eb4b3726fecd3a5a537bd5db186a6e173febba8a51b082b25a29afa3f9b7e6f9c4e8550db5ab2a2538b8187cf55657683a436bf
7
+ data.tar.gz: 11799aa695a8da035dab7b6bf757fc4420e94c5ee5b7f71f7151ae0bf76a0d124f309c9ae0cd9d2025b05bb2e16cb428bb78413d51aea137294836196242b193
@@ -1,95 +1,95 @@
1
- require 'cucumber/formatter/json'
2
- require 'net/http'
3
-
4
- module Cucumber
5
- module CalliopeImporter
6
- class Json < Formatter::Json
7
- def initialize(config)
8
- super
9
- if ENV['API_KEY'].nil? || ENV['PROFILE_ID'].nil?
10
- error = "API Key and/or Profile ID were not set. Please provide them in your cucumber call or profile like this API_KEY='API Key Here' PROFILE_ID='Profile ID Here'"
11
- print_error(error)
12
- exit
13
- end
14
- #Set calliope data
15
- @calliope_config = {
16
- 'api_key' => ENV['API_KEY'],
17
- 'profile_id' => ENV['PROFILE_ID']
18
- }
19
- if ENV['API_URL']
20
- @calliope_config['url'] = ENV['API_URL']
21
- else
22
- @calliope_config['url'] = 'https://app.calliope/pro'
23
- end
24
- check_profile_permission
25
- end
26
-
27
- def on_finished_testing(event)
28
- results = MultiJson.dump(@feature_hashes, pretty: true)
29
- @io.write(results)
30
- upload_to_api(results)
31
- end
32
-
33
- def upload_to_api(results)
34
- print "\nUploading to Calliope.pro"
35
- # Get metadata from test run
36
- @calliope_config['browser'] = ENV['BROWSER_VERSION'] || ENV['BROWSER'] || nil
37
- @calliope_config['os'] = RUBY_PLATFORM
38
- # Set url
39
- if @calliope_config['browser'].nil?
40
- print "\n[Optional] Could not determine browser and browser version, set ENV['BROWSER_VERSION'] in env.rb to manually set them."
41
- end
42
- api_call(results)
43
- end
44
-
45
- def api_call(results)
46
- # Make API call
47
- url = "#{@calliope_config['url']}/api/v2/profile/#{@calliope_config['profile_id']}/testresult?browser=#{@calliope_config['browser']}&os=#{@calliope_config['os']}"
48
- url = URI.parse(url)
49
- http = Net::HTTP.new(url.host, url.port)
50
- # Enable ssl when necessary
51
- if @calliope_config['url'].include? 'https://'
52
- http.use_ssl = true
53
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
54
- end
55
- header = {
56
- 'content-type' => 'application/json',
57
- 'x-api-key' => @calliope_config['api_key']
58
- }
59
- request = Net::HTTP::Post.new(url, header)
60
- request.body = results
61
- response = http.request(request)
62
- print "\nAPI response: #{response.body} \n\n"
63
- end
64
-
65
- def check_profile_permission
66
- url = "#{@calliope_config['url']}/api/v2/profile/#{@calliope_config['profile_id']}"
67
- url = URI.parse(url)
68
- http = Net::HTTP.new(url.host, url.port)
69
- # Enable ssl when necessary
70
- if @calliope_config['url'].include? 'https://'
71
- http.use_ssl = true
72
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
73
- end
74
- header = {
75
- 'content-type' => 'application/json',
76
- 'x-api-key' => @calliope_config['api_key']
77
- }
78
- request = Net::HTTP::Get.new(url, header)
79
- response = http.request(request)
80
-
81
- if response.code != '200'
82
- error = 'Not authorized for this calliope profile, exiting...'
83
- print_error(error)
84
- exit
85
- end
86
- end
87
-
88
- def print_error(message)
89
- print "\033[31m" # Sets console colors to red
90
- print "Error: #{message}"
91
- print "\033[0m" # Resets console colors
92
- end
93
- end
94
- end
1
+ require 'cucumber/formatter/json'
2
+ require 'net/http'
3
+
4
+ module Cucumber
5
+ module CalliopeImporter
6
+ class Json < Formatter::Json
7
+ def initialize(config)
8
+ super
9
+ if ENV['API_KEY'].nil? || ENV['PROFILE_ID'].nil?
10
+ error = "API Key and/or Profile ID were not set. Please provide them in your cucumber call or profile like this API_KEY='API Key Here' PROFILE_ID='Profile ID Here'"
11
+ print_error(error)
12
+ exit 1
13
+ end
14
+ #Set calliope data
15
+ @calliope_config = {
16
+ 'api_key' => ENV['API_KEY'],
17
+ 'profile_id' => ENV['PROFILE_ID']
18
+ }
19
+ if ENV['API_URL']
20
+ @calliope_config['url'] = ENV['API_URL']
21
+ else
22
+ @calliope_config['url'] = 'https://app.calliope/pro'
23
+ end
24
+ check_profile_permission
25
+ end
26
+
27
+ def on_finished_testing(event)
28
+ results = MultiJson.dump(@feature_hashes, pretty: true)
29
+ @io.write(results)
30
+ upload_to_api(results)
31
+ end
32
+
33
+ def upload_to_api(results)
34
+ print "\nUploading to Calliope.pro"
35
+ # Get metadata from test run
36
+ @calliope_config['browser'] = ENV['BROWSER_VERSION'] || ENV['BROWSER'] || nil
37
+ @calliope_config['os'] = RUBY_PLATFORM
38
+ # Set url
39
+ if @calliope_config['browser'].nil?
40
+ print "\n[Optional] Could not determine browser and browser version, set ENV['BROWSER_VERSION'] in env.rb to manually set them."
41
+ end
42
+ api_call(results)
43
+ end
44
+
45
+ def api_call(results)
46
+ # Make API call
47
+ url = "#{@calliope_config['url']}/api/v2/profile/#{@calliope_config['profile_id']}/testresult?browser=#{@calliope_config['browser']}&os=#{@calliope_config['os']}"
48
+ url = URI.parse(url)
49
+ http = Net::HTTP.new(url.host, url.port)
50
+ # Enable ssl when necessary
51
+ if @calliope_config['url'].include? 'https://'
52
+ http.use_ssl = true
53
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
54
+ end
55
+ header = {
56
+ 'content-type' => 'application/json',
57
+ 'x-api-key' => @calliope_config['api_key']
58
+ }
59
+ request = Net::HTTP::Post.new(url, header)
60
+ request.body = results
61
+ response = http.request(request)
62
+ print "\nAPI response: #{response.body} \n\n"
63
+ end
64
+
65
+ def check_profile_permission
66
+ url = "#{@calliope_config['url']}/api/v2/profile/#{@calliope_config['profile_id']}"
67
+ url = URI.parse(url)
68
+ http = Net::HTTP.new(url.host, url.port)
69
+ # Enable ssl when necessary
70
+ if @calliope_config['url'].include? 'https://'
71
+ http.use_ssl = true
72
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
73
+ end
74
+ header = {
75
+ 'content-type' => 'application/json',
76
+ 'x-api-key' => @calliope_config['api_key']
77
+ }
78
+ request = Net::HTTP::Get.new(url, header)
79
+ response = http.request(request)
80
+
81
+ if response.code != '200'
82
+ error = 'Not authorized for this calliope profile, exiting...'
83
+ print_error(error)
84
+ exit
85
+ end
86
+ end
87
+
88
+ def print_error(message)
89
+ print "\033[31m" # Sets console colors to red
90
+ print "Error: #{message}"
91
+ print "\033[0m" # Resets console colors
92
+ end
93
+ end
94
+ end
95
95
  end
@@ -1,5 +1,5 @@
1
1
  module Cucumber
2
2
  module CalliopeImporter
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
@@ -1,9 +1,9 @@
1
- require 'cucumber/cli/options'
2
-
3
- module Cucumber
4
- module Cli
5
- class Options
6
- BUILTIN_FORMATS['calliope_import'] = ['Cucumber::CalliopeImporter::Json', 'Prints the feature as JSON and uploads them to Calliope.pro']
7
- end
8
- end
1
+ require 'cucumber/cli/options'
2
+
3
+ module Cucumber
4
+ module Cli
5
+ class Options
6
+ BUILTIN_FORMATS['calliope_import'] = ['Cucumber::CalliopeImporter::Json', 'Prints the feature as JSON and uploads them to Calliope.pro']
7
+ end
8
+ end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-calliope_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maurice Wijnia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project:
97
- rubygems_version: 2.6.13
97
+ rubygems_version: 2.5.1
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: This gem adds a 'calliope-import' formatter to cucumber that uploads cucumber