Class: FlakyciRspec

Inherits:
Object
  • Object
show all
Defined in:
lib/flakyci_rspec.rb

Instance Method Summary collapse

Constructor Details

#initialize(_output) ⇒ FlakyciRspec

Returns a new instance of FlakyciRspec.



17
18
19
20
# File 'lib/flakyci_rspec.rb', line 17

def initialize(_output)
  @output = ''
  @env = Environments.new()
end

Instance Method Details

#close(_notification) ⇒ Object



57
58
59
# File 'lib/flakyci_rspec.rb', line 57

def close(_notification)
  @output
end

#dump_summary(notification) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 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_keyObject



61
62
63
# File 'lib/flakyci_rspec.rb', line 61

def project_key
  ENV["FLAKYCI_KEY"] 
end

#seed(seed) ⇒ Object



22
23
24
# File 'lib/flakyci_rspec.rb', line 22

def seed(seed)
  @seed = seed.seed
end

#urlObject



65
66
67
# File 'lib/flakyci_rspec.rb', line 65

def url
  ENV["FLAKYCI_URL"] || "https://www.flakyci.com/api"
end