class FlakyciRspec

Public Class Methods

new(_output) click to toggle source
# File lib/flakyci_rspec.rb, line 17
def initialize(_output)
  @output = ''
  @env = Environments.new()
end

Public Instance Methods

close(_notification) click to toggle source
# File lib/flakyci_rspec.rb, line 57
def close(_notification)
  @output
end
dump_summary(notification) click to toggle source
# File lib/flakyci_rspec.rb, line 26
def dump_summary(notification)
  results = notification.examples.map do |example|
    location = example.location.split(':')

    {
      module: example.example_group,
      name: example.description,
      line: location[1],
      file: location[0],
      status: example.execution_result.status,
      duration: (example.execution_result.run_time * 1000).round
    }
  end
  build = @env.get_env()
  build[:suite] = {
    seed: @seed,
    results: results
  }
  print(project_key())
  variables = {
    build: build,
    version: 1,
    project_key: project_key()
  }  
  res = HTTP.post(url(), :json => {query: MUTATION, variables: variables})
  res = JSON.parse(res)
  if res["errors"]
    print(res["errors"][0]["message"])
  end
end
project_key() click to toggle source
# File lib/flakyci_rspec.rb, line 61
def project_key
  ENV["FLAKYCI_KEY"] 
end
seed(seed) click to toggle source
# File lib/flakyci_rspec.rb, line 22
def seed(seed)
  @seed = seed.seed
end
url() click to toggle source
# File lib/flakyci_rspec.rb, line 65
def url
  ENV["FLAKYCI_URL"] || "https://www.flakyci.com/api"
end