Module: QTest::REST::API

Includes:
HTTParty, Module, Project, Release, TestCase, TestCycle, TestRun, TestSuite, Utils
Included in:
Client
Defined in:
lib/qtest/rest/api.rb

Constant Summary collapse

BASE_PATH =
'/api/v3'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Module

#module, #modules

Methods included from Utils

#decode_response_body, #delete, #get, #handle_response, #post, #put

Methods included from TestCase

#create_test_case, #test_case, #test_case_version, #test_case_versions, #test_cases, #test_step

Methods included from TestSuite

#create_test_suite, #move_test_suite, #test_suite, #test_suites, #update_test_suite

Methods included from TestRun

#create_test_run, #delete_test_run, #execution_statuses, #move_test_run, #submit_test_log, #test_run, #test_run_fields, #test_runs, #update_test_run

Methods included from TestCycle

#create_test_cycle, #delete_test_cycle, #move_test_cycle, #test_cycle, #test_cycles, #update_test_cycle

Methods included from Release

#release, #releases

Methods included from Project

#project, #projects

Instance Attribute Details

#tokenObject

The API token passed in the Authorization header after successfully using the auth method.



31
32
33
# File 'lib/qtest/rest/api.rb', line 31

def token
  @token
end

Class Method Details

.included(base) ⇒ Object



25
26
27
# File 'lib/qtest/rest/api.rb', line 25

def self.included(base)
  base.include HTTParty
end

Instance Method Details

#all(type, opts = {}) ⇒ Object



67
68
69
# File 'lib/qtest/rest/api.rb', line 67

def all(type, opts = {})
  self.send(methodize(type).pluralize, opts)
end

#auth(opts = {}) ⇒ String

Authenticate with the QTest REST API using credentials.

If successful, an API token is returned and used on future requests.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/qtest/rest/api.rb', line 42

def auth(opts = {})
  query = QueryBuilder.new
                      .options(:without_api_path)
                      .with('/api/login')
                      .header(:content_type,
                              'application/x-www-form-urlencoded')
                      .data(j_username: opts[:username])
                      .data(j_password: opts[:password])
                      .build

  @token = post(query, raw: true)
  self.class.send(:headers, 'Authorization' => @token)

  @token
end

#create(type, opts = {}) ⇒ Object



75
76
77
# File 'lib/qtest/rest/api.rb', line 75

def create(type, opts = {})
  self.send("create_#{methodize(type)}", opts)
end

#fields(opts = {}) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/qtest/rest/api.rb', line 58

def fields(opts = {})
  query = QueryBuilder.new
                      .project(opts[:project])
                      .with(:settings, opts[:type], :fields)
                      .build

  get(query)
end

#move(type, opts = {}) ⇒ Object



79
80
81
# File 'lib/qtest/rest/api.rb', line 79

def move(type, opts = {})
  self.send("move_#{methodize(type)}", opts)
end

#unique(type, opts = {}) ⇒ Object



71
72
73
# File 'lib/qtest/rest/api.rb', line 71

def unique(type, opts = {})
  self.send(methodize(type), opts)
end