Class: ATM::Services::TestCase
- Includes:
- Helper::TestCase
- Defined in:
- lib/atm_ruby/services/test_case.rb
Overview
ATM::Services::TestCase provides methods for working with test cases
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#project_id ⇒ Object
Returns the value of attribute project_id.
Attributes inherited from Base
#[], #auth_header, #header, #response
Instance Method Summary collapse
-
#add_attachment(_test_case_id) ⇒ Object
Adds attachment to a test case.
-
#create(body) ⇒ Object
Creates new test case.
-
#create_new_test_result(test_data) ⇒ Object
Create new result for test case.
-
#delete(test_case_id) ⇒ Object
Deletes test case.
-
#find(test_case_id) ⇒ Object
Finds specific test case.
-
#initialize(**options) ⇒ TestCase
constructor
A new instance of TestCase.
-
#process_result(test_data) ⇒ Object
Creates hash for new test result.
-
#search(query_string) ⇒ Object
Searches for test cases based on the provided quiry.
-
#update(test_case_id, body) ⇒ Object
Updates test case.
Methods included from Helper::TestCase
Methods inherited from Base
Constructor Details
#initialize(**options) ⇒ TestCase
Returns a new instance of TestCase.
13 14 15 16 17 |
# File 'lib/atm_ruby/services/test_case.rb', line 13 def initialize(**) @project_id = .delete(:project_id) @environment = .delete(:environment) super() end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
11 12 13 |
# File 'lib/atm_ruby/services/test_case.rb', line 11 def environment @environment end |
#project_id ⇒ Object
Returns the value of attribute project_id.
11 12 13 |
# File 'lib/atm_ruby/services/test_case.rb', line 11 def project_id @project_id end |
Instance Method Details
#add_attachment(_test_case_id) ⇒ Object
Adds attachment to a test case
91 92 93 94 95 96 |
# File 'lib/atm_ruby/services/test_case.rb', line 91 def (_test_case_id) # TODO: need to fix this. warn 'Not implemented at the moment' # self.class.get("/rest/kanoahtests/1.0/testcase/#{test_case_id}/attachment", headers: auth_header).tap do |res| # raise ATM::TestCaseError, response unless response.code == 201 # end end |
#create(body) ⇒ Object
Creates new test case
26 27 28 29 30 31 |
# File 'lib/atm_ruby/services/test_case.rb', line 26 def create(body) self.class.post('/rest/kanoahtests/1.0/testcase', body: body.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 201 end end |
#create_new_test_result(test_data) ⇒ Object
Create new result for test case
106 107 108 109 110 111 |
# File 'lib/atm_ruby/services/test_case.rb', line 106 def create_new_test_result(test_data) self.class.post('/rest/kanoahtests/1.0/testresult', body: test_data.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end |
#delete(test_case_id) ⇒ Object
Deletes test case
52 53 54 55 56 57 |
# File 'lib/atm_ruby/services/test_case.rb', line 52 def delete(test_case_id) self.class.delete("/rest/kanoahtests/1.0/testcase/#{test_case_id}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 204 end end |
#find(test_case_id) ⇒ Object
Finds specific test case
65 66 67 68 69 70 |
# File 'lib/atm_ruby/services/test_case.rb', line 65 def find(test_case_id) self.class.get("/rest/kanoahtests/1.0/testcase/#{test_case_id}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end |
#process_result(test_data) ⇒ Object
Creates hash for new test result
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/atm_ruby/services/test_case.rb', line 116 def process_result(test_data) { 'projectKey' => test_data.fetch(:project_id, project_id), 'testCaseKey' => test_data[:test_case_id], 'status' => test_data.fetch(:status, nil), 'environment' => test_data.fetch(:environment, environment), 'userKey' => test_data.fetch(:username, nil), 'comment' => test_data.fetch(:comment, nil), 'executionTime' => test_data.fetch(:execution_time, nil), 'executionDate' => test_data.fetch(:execution_date, nil), 'scriptResults' => test_data.fetch(:script_results, nil) }.delete_if { |_k, v| v.nil? } end |
#search(query_string) ⇒ Object
Searches for test cases based on the provided quiry
78 79 80 81 82 83 |
# File 'lib/atm_ruby/services/test_case.rb', line 78 def search(query_string) self.class.get("/rest/kanoahtests/1.0/testcase/search?query=#{query_string}", headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end |
#update(test_case_id, body) ⇒ Object
Updates test case
39 40 41 42 43 44 |
# File 'lib/atm_ruby/services/test_case.rb', line 39 def update(test_case_id, body) self.class.put("/rest/kanoahtests/1.0/testcase/#{test_case_id}", body: body.to_json, headers: auth_header).tap do |res| set_response(res) raise ATM::TestCaseError, response unless code == 200 end end |