testrail_api 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,69 +4,71 @@ module TestRail
4
4
  #
5
5
  # @see http://docs.gurock.com/testrail-api2/reference-runs
6
6
  # Use the following API methods to request details about test runs and to create or modify test runs.
7
+ module Runs
8
+ #
9
+ # Returns an existing test run. Please see get_tests for the list of included tests in this run.
10
+ #
11
+ # :run_id The ID of the test run
12
+ #
13
+ def run(run_id)
14
+ get("get_run/#{run_id}")
15
+ end
7
16
 
8
- #
9
- # Returns an existing test run. Please see get_tests for the list of included tests in this run.
10
- #
11
- # :run_id The ID of the test run
12
- #
13
- def run(run_id)
14
- get("get_run/#{run_id}")
15
- end
17
+ #
18
+ # Returns a list of test runs for a project.
19
+ # Only returns those test runs that are not part of a test plan (please see get_plans/get_plan for this).
20
+ #
21
+ # :project_id The ID of the project
22
+ #
23
+ def runs(project_id)
24
+ get("get_runs/#{project_id}")
25
+ end
16
26
 
17
- #
18
- # Returns a list of test runs for a project.
19
- # Only returns those test runs that are not part of a test plan (please see get_plans/get_plan for this).
20
- #
21
- # :project_id The ID of the project
22
- #
23
- def runs(project_id)
24
- get("get_runs/#{project_id}")
25
- end
27
+ #
28
+ # Creates a new test run.
29
+ #
30
+ # @param [Integer, String] project_id The ID of the project the test run should be added to
31
+ # @param data [Hash]: A customizable set of options
32
+ # @option data [Integer] :suite_id The ID of the test suite for the test run (optional if the project is operating in single suite mode, required otherwise)
33
+ # @option data [String] :name The name of the test run
34
+ # @option data [String] :description The description of the test run
35
+ # @option data [Integer] :milestone_id The ID of the milestone to link to the test run
36
+ # @option data [Integer] :assignedto_id The ID of the user the test run should be assigned to
37
+ # @option data [Boolean] :include_all True for including all test cases of the test suite and false for a custom case selection (default: true)
38
+ # @option data [Array<Integer>] :case_ids An array of case IDs for the custom case selection
39
+ # @return # TODO:
40
+ # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
41
+ def add_run(project_id, data)
42
+ post("add_run/#{project_id}", body: data.to_json)
43
+ end
26
44
 
27
- #
28
- # Creates a new test run.
29
- #
30
- # @param [Integer, String] project_id The ID of the project the test run should be added to
31
- # @param data [Hash]: A customizable set of options
32
- # @option data [Integer] :suite_id The ID of the test suite for the test run (optional if the project is operating in single suite mode, required otherwise)
33
- # @option data [String] :name The name of the test run
34
- # @option data [String] :description The description of the test run
35
- # @option data [Integer] :milestone_id The ID of the milestone to link to the test run
36
- # @option data [Integer] :assignedto_id The ID of the user the test run should be assigned to
37
- # @option data [Boolean] :include_all True for including all test cases of the test suite and false for a custom case selection (default: true)
38
- # @option data [Array<Integer>] :case_ids An array of case IDs for the custom case selection
39
- # @return # TODO:
40
- # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
41
- def add_run(project_id, data)
42
- post("add_run/#{project_id}", data)
43
- end
45
+ #
46
+ # Updates an existing test run (partial updates are supported, i.e. you can submit and update specific fields only).
47
+ # With the exception of the suite_id and assignedto_id fields, this method supports the same POST fields as add_run.
48
+ #
49
+ # :run_id The ID of the test run
50
+ #
51
+ def update_run(run_id, data)
52
+ post("update_run/#{run_id}", body: data.to_json)
53
+ end
44
54
 
45
- #
46
- # Updates an existing test run (partial updates are supported, i.e. you can submit and update specific fields only).
47
- #
48
- # :run_id The ID of the test run
49
- #
50
- def update_run(run_id, data)
51
- post("update_run/#{run_id}", data)
52
- end
55
+ #
56
+ # Closes an existing test run and archives its tests & results.
57
+ #
58
+ # :run_id The ID of the test run
59
+ #
60
+ def close_run(run_id, data)
61
+ post("close_run/#{run_id}", data)
62
+ end
53
63
 
54
- #
55
- # Closes an existing test run and archives its tests & results.
56
- #
57
- # :run_id The ID of the test run
58
- #
59
- def close_run(run_id, data)
60
- post("close_run/#{run_id}", data)
61
- end
62
-
63
- #
64
- # Deletes an existing test run.
65
- #
66
- # :run_id The ID of the test run
67
- #
68
- def delete_run(run_id, data)
69
- post("delete_run/#{run_id}", data)
64
+ #
65
+ # Deletes an existing test run.
66
+ #
67
+ # :run_id The ID of the test run
68
+ #
69
+ def delete_run(run_id, data)
70
+ post("delete_run/#{run_id}", data)
71
+ end
70
72
  end
71
73
  end
72
74
  end
@@ -5,61 +5,58 @@ module TestRail
5
5
  # @see http://docs.gurock.com/testrail-api2/reference-sections
6
6
  # Use the following API methods to request details about sections and to create or modify sections.
7
7
  # Sections are used to group and organize test cases in test suites.
8
+ module Sections
9
+ #
10
+ # Returns an existing section.
11
+ #
12
+ # :section_id The ID of the section
13
+ #
14
+ def section(section_id)
15
+ get("get_section/#{section_id}")
16
+ end
8
17
 
9
- #
10
- # Returns an existing section.
11
- #
12
- # :section_id The ID of the section
13
- #
14
- def section(section_id)
15
- get("get_section/#{section_id}")
16
- end
17
-
18
- #
19
- # Returns a list of sections for a project and test suite.
20
- #
21
- # :project_id The ID of the project
22
- # :suite_id The ID of the test suite (optional if the project is operating in single suite mode)
23
- #
24
- def sections(project_id, suite_id)
25
- get("get_sections/#{project_id}&suite_id=#{suite_id}")
26
- end
18
+ #
19
+ # Returns a list of sections for a project and test suite.
20
+ #
21
+ # :project_id The ID of the project
22
+ # :suite_id The ID of the test suite (optional if the project is operating in single suite mode)
23
+ #
24
+ def sections(project_id, suite_id)
25
+ get("get_sections/#{project_id}&suite_id=#{suite_id}")
26
+ end
27
27
 
28
- def section_by_name(project_id, suite_id, section_name, ignore_case = true)
29
- if ignore_case
30
- sections(project_id, suite_id).find { |section| section['name'].casecmp(section_name) == 0 }
31
- else
28
+ def section_by_name(project_id, suite_id, section_name)
32
29
  sections(project_id, suite_id).find { |section| section['name'] == section_name }
33
30
  end
34
- end
35
31
 
36
- #
37
- # Creates a new section.
38
- #
39
- # :project_id The ID of the project
40
- #
41
- def add_section(project_id, data)
42
- post("add_section/#{project_id}", data)
43
- end
32
+ #
33
+ # Creates a new section.
34
+ #
35
+ # :project_id The ID of the project
36
+ #
37
+ def add_section(project_id, data)
38
+ post("add_section/#{project_id}", data)
39
+ end
44
40
 
45
- #
46
- # Updates an existing section (partial updates are supported, i.e. you can submit and update specific fields only).
47
- #
48
- # :section_id The ID of the section
49
- #
50
- def update_section(section_id, data)
51
- post("update_section/#{section_id}", data)
52
- end
41
+ #
42
+ # Updates an existing section (partial updates are supported, i.e. you can submit and update specific fields only).
43
+ #
44
+ # :section_id The ID of the section
45
+ #
46
+ def update_section(section_id, data)
47
+ post("update_section/#{section_id}", data)
48
+ end
53
49
 
54
- #
55
- # Updates an existing section (partial updates are supported, i.e. you can submit and update specific fields only).
56
- # Please note: Deleting a section cannot be undone and also deletes all related test cases
57
- # as well as active tests & results, i.e. tests & results that weren't closed (archived) yet.
58
- #
59
- # :section_id The ID of the section
60
- #
61
- def delete_section(section_id)
62
- post("delete_section/#{section_id}")
50
+ #
51
+ # Updates an existing section (partial updates are supported, i.e. you can submit and update specific fields only).
52
+ # Please note: Deleting a section cannot be undone and also deletes all related test cases
53
+ # as well as active tests & results, i.e. tests & results that weren't closed (archived) yet.
54
+ #
55
+ # :section_id The ID of the section
56
+ #
57
+ def delete_section(section_id)
58
+ post("delete_section/#{section_id}")
59
+ end
63
60
  end
64
61
  end
65
62
  end
@@ -4,16 +4,17 @@ module TestRail
4
4
  #
5
5
  # @see http://docs.gurock.com/testrail-api2/reference-statuses
6
6
  # Use the following API methods to request details about test statuses.
7
-
8
7
  # Each status has a unique ID, a name (system name) as well as a label (display name).
9
8
  # The color related fields specify the different colors used for a status and are RGB colors.
10
9
  # The following system statuses are available by default.
11
10
  # You can add additional custom statuses under Administration > Customizations in TestRail.
12
-
13
- # @return a list of available_contexts test statuses.
14
- # @see http://docs.gurock.com/testrail-api2/reference-statuses#get_statuses
15
- def statuses
16
- get('get_statuses')
11
+ module Statuses
12
+ #
13
+ # @return a list of available_contexts test statuses.
14
+ # @see http://docs.gurock.com/testrail-api2/reference-statuses#get_statuses
15
+ def statuses
16
+ get('get_statuses')
17
+ end
17
18
  end
18
19
  end
19
20
  end
@@ -4,40 +4,42 @@ module TestRail
4
4
  #
5
5
  # @see http://docs.gurock.com/testrail-api2/reference-suites
6
6
  # Use the following API methods to request details about test suites and to create or modify test suites.
7
+ module Suites
8
+ #
9
+ # Returns an existing test suite.
10
+ #
11
+ # :suite_id The ID of the test suite
12
+ #
13
+ def suite(suite_id)
14
+ get("get_suite/#{suite_id}")
15
+ end
7
16
 
8
- #
9
- # Returns an existing test suite.
10
- #
11
- # :suite_id The ID of the test suite
12
- #
13
- def suite(suite_id)
14
- get("get_suite/#{suite_id}")
15
- end
16
-
17
- def suite_by_name(project_id, suite_name, ignore_case = true)
18
- if ignore_case
17
+ def suite_by_name(project_id, suite_name)
19
18
  suites(project_id).find { |suite| suite['name'].casecmp(suite_name) == 0 }
20
- else
21
- suites(project_id).find { |suite| suite['name'] == suite_name }
22
19
  end
23
- end
24
20
 
25
- #
26
- # Returns a list of test suites for a project.
27
- #
28
- # :project_id The ID of the project
29
- #
30
- def suites(project_id)
31
- get("get_suites/#{project_id}")
32
- end
21
+ #
22
+ # Returns a list of test suites for a project.
23
+ #
24
+ # :project_id The ID of the project
25
+ #
26
+ def suites(project_id)
27
+ get("get_suites/#{project_id}")
28
+ end
33
29
 
34
- #
35
- # Creates a new test suite.
36
- #
37
- # :project_id The ID of the project the test suite should be added to
38
- #
39
- def add_suite(project_id, data)
40
- post("add_suite/#{project_id}", data)
30
+ def suites_by_project_name(project_name)
31
+ project_id = project_by_name(project_name).fetch('id')
32
+ suites(project_id)
33
+ end
34
+
35
+ #
36
+ # Creates a new test suite.
37
+ #
38
+ # :project_id The ID of the project the test suite should be added to
39
+ #
40
+ def add_suite(project_id, data)
41
+ post("add_suite/#{project_id}", data)
42
+ end
41
43
  end
42
44
  end
43
45
  end
@@ -4,41 +4,38 @@ module TestRail
4
4
  # Use the following API methods to request details about tests.
5
5
  #
6
6
  # @see http://docs.gurock.com/testrail-api2/reference-tests
7
- #
8
- # Returns an existing test by its ID
9
- ##
10
- # @param [Integer, String] test_id The ID of the test
11
- # @return an existing test by its ID
12
- # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
13
- def test(test_id)
14
- get("get_test/#{test_id}")
15
- end
7
+ module Tests
8
+ #
9
+ # Returns an existing test by its ID
10
+ #
11
+ # @param [Integer, String] test_id The ID of the test
12
+ # @return an existing test by its ID
13
+ # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
14
+ def test(test_id)
15
+ get("get_test/#{test_id}")
16
+ end
16
17
 
17
- # TODO: add documentation
18
- def test_by_title(run_id, test_title, ignore_case = true)
19
- if ignore_case
18
+ # TODO: add documentation
19
+ def test_by_title(run_id, test_title)
20
20
  tests(run_id).find { |test| test['title'].casecmp(test_title) == 0 }
21
- else
22
- tests(run_id).find { |test| test['title'] == test_title }
23
-
24
21
  end
25
- end
26
22
 
27
- # TODO: add documentation
28
- def test_id_by_title(run_id, test_title)
29
- test_by_title(run_id, test_title)['id']
30
- end
23
+ # TODO: add documentation
24
+ def test_id_by_title(run_id, test_title)
25
+ test_by_title(run_id, test_title)['id']
26
+ end
31
27
 
32
- #
33
- # Returns a list of tests for a test run.
34
- #
35
- # # TODO: finish method and documentation
36
- # @param [Integer, String] run_id The ID of the test run
37
- # @option [String] status_id
38
- # @return an existing test by its ID
39
- # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
40
- def tests(run_id)
41
- get("get_tests/#{run_id}")
28
+ #
29
+ # Returns a list of tests for a test run.
30
+ #
31
+ # TODO: finish method and documentation
32
+ # @param [Integer, String] run_id The ID of the test run
33
+ # @option [String] status_id
34
+ # @return an existing test by its ID
35
+ # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
36
+ def tests(run_id)
37
+ get("get_tests/#{run_id}")
38
+ end
42
39
  end
43
40
  end
44
41
  end
@@ -3,30 +3,31 @@ module TestRail
3
3
  # Methods for the Users API
4
4
  #
5
5
  # @see http://docs.gurock.com/testrail-api2/reference-users
6
- #
6
+ module Users
7
+ #
8
+ # Returns an existing user.
9
+ #
10
+ # :user_id The ID of the user
11
+ #
12
+ def user(user_id)
13
+ get("get_user/#{user_id}")
14
+ end
7
15
 
8
- # Returns an existing user.
9
- #
10
- # :user_id The ID of the user
11
- #
12
- def user(user_id)
13
- get("get_user/#{user_id}")
14
- end
16
+ #
17
+ # Returns a list of users.
18
+ #
19
+ def users
20
+ get('get_users')
21
+ end
15
22
 
16
- #
17
- # Returns a list of users.
18
- #
19
- def users
20
- get('get_users')
21
- end
22
-
23
- #
24
- # Returns an existing user by his/her email address.
25
- #
26
- # :email The email address to get the user for
27
- #
28
- def user_by_email(email)
29
- get("get_user_by_email&email=#{email}")
23
+ #
24
+ # Returns an existing user by his/her email address.
25
+ #
26
+ # :email The email address to get the user for
27
+ #
28
+ def user_by_email(email)
29
+ get("get_user_by_email&email=#{email}")
30
+ end
30
31
  end
31
32
  end
32
33
  end