Class: Lita::Handlers::GhostInspectorTests

Inherits:
Handler
  • Object
show all
Includes:
LitaGhostInspector::API, LitaGhostInspector::Config, LitaGhostInspector::Utility
Defined in:
lib/lita/handlers/ghost_inspector_tests.rb

Instance Method Summary collapse

Methods included from LitaGhostInspector::Utility

#seconds_to_human

Methods included from LitaGhostInspector::API

#gi_api, #gi_get

Methods included from LitaGhostInspector::Config

#config

Instance Method Details

#execute(response) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/lita/handlers/ghost_inspector_tests.rb', line 34

def execute(response)
  test_name = response.matches[0][0]
  test_ids = test_ids_by_name test_name
  test_ids = [test_name] unless test_ids.any?
  execute_response = test_ids.map do |test_id|
    execute_response = gi_get "/tests/#{test_id}/execute", immediate: true
    if execute_response == {}
      test = test(test_id) || test(test_ids_by_name(test_id)[0])
      "#{test["name"]} (#{test["_id"]})"
    end
  end.join ", "

  response.reply "Started #{execute_response}..."
rescue Exception => e
  response.reply "GhostInspector Test Execute failed: #{e}"
end

#list(response) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lita/handlers/ghost_inspector_tests.rb', line 16

def list(response)
  tests = gi_get "/tests"
  tests_response = tests.map{ |test|
    "`#{test["_id"]}` - " +
    "#{test["name"]} - " +
    "#{test["passing"] ? "Passing" : "*Not passing*"}" +
    " with screenshot " +
    "#{test["screenshotComparePassing"] ? "passing" : "*not passing*"}" +
    ". " +
    "Runs #{seconds_to_human test["testFrequency"]}. "
  }
  response.reply tests_response.join "\n"
end