class Specstat::TestRun
Attributes
results[R]
Public Class Methods
new()
click to toggle source
# File lib/specstat/test_run.rb, line 9 def initialize @results = [] end
Public Instance Methods
add(example)
click to toggle source
# File lib/specstat/test_run.rb, line 13 def add(example) result = TestResult.new(example.full_description, example.execution_result.status.to_s, example.execution_result.run_time) @results.push(result) end
submit!()
click to toggle source
# File lib/specstat/test_run.rb, line 20 def submit! Specstat::Reporter.logger.info "Sending #{@results.size} results to Specstat..." url = URI.parse(Reporter.endpoint) url.path = "/api/v1/raw_test_run" req = Net::HTTP::Post.new(url.to_s, "Authorization" => "Bearer #{Reporter.api_token}", "Content-Type" => "application/json", "Accept" => "application/json", "User-Agent" => "Specstat RSpec Reporter #{Reporter::VERSION}") req.body = @results.map(&:to_h).to_json http = Net::HTTP.new(url.host, url.port) http.use_ssl = true res = http.request(req) res.code == 201 end