Class: Swiftrail::Testrail::Api::Client
- Inherits:
-
Object
- Object
- Swiftrail::Testrail::Api::Client
- Defined in:
- lib/swiftrail/testrail/api/client.rb
Instance Method Summary collapse
- #all_tests ⇒ TestRailTest
-
#initialize(base_url, username, password, run_id) ⇒ Client
constructor
A new instance of Client.
- #publish_results(results) ⇒ Object
Constructor Details
#initialize(base_url, username, password, run_id) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 |
# File 'lib/swiftrail/testrail/api/client.rb', line 12 def initialize(base_url, username, password, run_id) @conn = connection(URI.parse(base_url)) @run_id = run_id @username = username @password = password end |
Instance Method Details
#all_tests ⇒ TestRailTest
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/swiftrail/testrail/api/client.rb', line 30 def all_tests response = conn.request(get_request(tests_for_run_path)) raise Error::InvalidRequest.new(response) if response.code == '400' raise Error::NoPermission(response) if response.code == '403' raise Error::Unknown(response), response.code unless response.code == '200' JSON.parse(response.body).map do |item| TestRailTest.from_json(item) end end |
#publish_results(results) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/swiftrail/testrail/api/client.rb', line 19 def publish_results(results) response = conn.request(post_request(publish_result_path, results)) raise Error::InvalidRequest.new(response) if response.code == '400' raise Error::NoPermission.new(response) if response.code == '403' raise Error::Unknown.new(response), response.code unless response.code == '200' true end |