Module: WrataApi::QueueMethods

Included in:
WrataApi
Defined in:
lib/wrata_api/queue_methos.rb

Overview

Methods for working with queue

Instance Method Summary collapse

Instance Method Details

#add_tests_to_queue(test_list, options = {}) ⇒ Nothing

Add several tests to queue

Parameters:

  • test_list (Array, String)

    tests to add

  • options (Hash) (defaults to: {})

    option to each test

Returns:

  • (Nothing)


52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/wrata_api/queue_methos.rb', line 52

def add_tests_to_queue(test_list, options = {})
  uri = URI.parse("#{@uri}/queue/add_tests")

  options = queue_item_default_values(options)
  body = {
    'test_paths[]' => test_list,
    'branch' => options[:branch],
    'location' => options[:location],
    'spec_browser' => options[:browser]
  }
  perform_post(uri, body)
end

#add_to_queue(tests_to_add, options = {}) ⇒ Nothing

Add test to queue

Parameters:

  • tests_to_add (String)

    path to add test

  • options (Hash) (defaults to: {})

    string of some options

Returns:

  • (Nothing)


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/wrata_api/queue_methos.rb', line 25

def add_to_queue(tests_to_add, options = {})
  uri = URI.parse("#{@uri}/queue/add_test")

  options = queue_item_default_values(options)
  body = {
    'test_path' => tests_to_add,
    'branch' => options[:branch],
    'location' => options[:location],
    'spec_browser' => options[:browser]
  }
  perform_post(uri, body)
end

#clear_tests_listNothing

Clear test in queue

Returns:

  • (Nothing)


8
9
10
11
# File 'lib/wrata_api/queue_methos.rb', line 8

def clear_tests_list
  uri = URI.parse("#{@uri}/queue/clear_tests")
  perform_post(uri)
end

#queue_item_default_values(options) ⇒ Hash

Add default value to queue item

Parameters:

  • options (Hash)

    values for add to queue

Returns:

  • (Hash)

    after adding default



41
42
43
44
45
46
# File 'lib/wrata_api/queue_methos.rb', line 41

def queue_item_default_values(options)
  options[:branch] ||= 'develop'
  options[:location] ||= 'info us'
  options[:browser] ||= 'default'
  options
end

#tests_in_queueArray<Hash>

Get list of tests in queue

Returns:

  • (Array<Hash>)

    test list data



15
16
17
18
19
# File 'lib/wrata_api/queue_methos.rb', line 15

def tests_in_queue
  uri = URI.parse("#{@uri}/runner/updated_data")
  response = perform_get(uri)
  response['queue_data']['tests']
end