Class: ReportFactory::Rspec::API
- Inherits:
-
Object
- Object
- ReportFactory::Rspec::API
- Defined in:
- lib/report_factory/rspec/api.rb
Overview
An RSpec formatter that formats json from the test run
Class Method Summary collapse
- .base_url ⇒ Object
- .create_report_url ⇒ Object
- .format_headers ⇒ Object
- .format_payload(report_hash) ⇒ Object
- .project_name ⇒ Object
- .send_report(report_hash) ⇒ Object
- .tags ⇒ Object
- .x_api_key ⇒ Object
Class Method Details
.base_url ⇒ Object
41 42 43 |
# File 'lib/report_factory/rspec/api.rb', line 41 def self.base_url ReportFactory::Rspec.url end |
.create_report_url ⇒ Object
53 54 55 |
# File 'lib/report_factory/rspec/api.rb', line 53 def self.create_report_url URI.parse("#{base_url}/api/v1/projects/#{project_name}/reports/rspec") end |
.format_headers ⇒ Object
20 21 22 23 24 25 |
# File 'lib/report_factory/rspec/api.rb', line 20 def self.format_headers { 'Content-Type': 'application/json', 'X-API-KEY' => x_api_key } end |
.format_payload(report_hash) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/report_factory/rspec/api.rb', line 27 def self.format_payload(report_hash) attributes = { tags: }.merge(report_hash) { data: { type: 'rspec_report', attributes: attributes } } end |
.project_name ⇒ Object
45 46 47 |
# File 'lib/report_factory/rspec/api.rb', line 45 def self.project_name ReportFactory::Rspec.project_name end |
.send_report(report_hash) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/report_factory/rspec/api.rb', line 11 def self.send_report(report_hash) uri = create_report_url request = Net::HTTP::Post.new(uri.request_uri, format_headers) request.body = format_payload(report_hash).to_json net_http = Net::HTTP.new(uri.host, uri.port) net_http.use_ssl = true if uri.scheme == 'https' net_http.request(request) end |
.tags ⇒ Object
49 50 51 |
# File 'lib/report_factory/rspec/api.rb', line 49 def self. ReportFactory::Rspec. end |
.x_api_key ⇒ Object
37 38 39 |
# File 'lib/report_factory/rspec/api.rb', line 37 def self.x_api_key ReportFactory::Rspec.auth_token end |