Class: OnlyofficeTestrailWrapper::Testrail2
- Inherits:
-
TestrailApiObject
- Object
- TestrailApiObject
- OnlyofficeTestrailWrapper::Testrail2
- Extended by:
- RequestsHelper
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail.rb
Overview
Main class for working with testrail dvd_copy = Project.init_project_by_name(‘AVS Disc Creator’) compete_test_suit= dvd_copy.init_suite_by_name(‘Complete Test Suite’) test_run_from_api = compete_test_suit.start_test_run(‘TestRunName’, “Simple description”) incompleted_test = test_run_from_api.get_incomplete_tests() while(incomplete_test.length > 0)
current_test = incomplete_test.sample
p current_test.title
current_test.add_result(Testrail2::TEST_RESULT_OK, 'description','version')
incomplete_test = test_run_from_api.get_incomplete_tests()
end1
Constant Summary collapse
- CONFIG_LOCATION =
Returns default config location.
"#{Dir.home}/.gem-onlyoffice_testrail_wrapper/config.yml".freeze
Class Attribute Summary collapse
- .admin_pass ⇒ Object
- .admin_user ⇒ Object
-
.testrail_url ⇒ Object
Returns the value of attribute testrail_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#available? ⇒ True, False
Check if Testrail connection is available.
- #create_new_project(name, announcement = '', show_announcement = true) ⇒ Object
-
#get_project_by_id(id) ⇒ Array, ProjectTestrail
Get all projects on testrail.
-
#get_project_by_name(name) ⇒ TestrailProject?
Get Testrail project by it’s name.
-
#get_projects ⇒ Array<TestrailProject>
Get all projects on testrail.
-
#init_project_by_name(name) ⇒ TestrailProject
Initialize project by it’s name.
-
#project(name_or_id) ⇒ Object
region PROJECT.
Methods included from RequestsHelper
http_get, http_post, send_request
Methods inherited from TestrailApiObject
#init_from_hash, #name_id_pairs
Class Attribute Details
.admin_pass ⇒ Object
64 65 66 67 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 64 def admin_pass read_keys unless @admin_pass @admin_pass end |
.admin_user ⇒ Object
59 60 61 62 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 59 def admin_user read_keys unless @admin_user @admin_user end |
.testrail_url ⇒ Object
Returns the value of attribute testrail_url.
34 35 36 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 34 def testrail_url @testrail_url end |
Class Method Details
.get_testrail_address ⇒ Object
69 70 71 72 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 69 def get_testrail_address read_keys unless testrail_url testrail_url end |
.read_keys ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 43 def read_keys @testrail_url = ENV.fetch('TESTRAIL_URL', 'http://unknown.url') @admin_user = ENV.fetch('TESTRAIL_USER', nil) @admin_pass = ENV.fetch('TESTRAIL_PASSWORD', nil) return unless @admin_user.nil? && @admin_pass.nil? begin yaml = YAML.load_file(CONFIG_LOCATION) @testrail_url = yaml['url'] @admin_user = yaml['user'] @admin_pass = yaml['password'] rescue Errno::ENOENT raise Errno::ENOENT, "No user of passwords found in #{CONFIG_LOCATION}. Please create correct config" end end |
Instance Method Details
#available? ⇒ True, False
Check if Testrail connection is available
139 140 141 142 143 144 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 139 def available? get_projects true rescue StandardError false end |
#create_new_project(name, announcement = '', show_announcement = true) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 98 def create_new_project(name, announcement = '', show_announcement = true) new_project = TestrailProject.new.init_from_hash(Testrail2.http_post('index.php?/api/v2/add_project', name: StringHelper.warnstrip!(name.to_s), announcement: announcement, show_announcement: show_announcement)) OnlyofficeLoggerHelper.log "Created new project: #{new_project.name}" new_project.instance_variable_set(:@testrail, self) new_project end |
#get_project_by_id(id) ⇒ Array, ProjectTestrail
Get all projects on testrail
118 119 120 121 122 123 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 118 def get_project_by_id(id) project = TestrailProject.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_project/#{id}")) OnlyofficeLoggerHelper.log("Initialized project: #{project.name}") project.instance_variable_set(:@testrail, self) project end |
#get_project_by_name(name) ⇒ TestrailProject?
Get Testrail project by it’s name
128 129 130 131 132 133 134 135 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 128 def get_project_by_name(name) projects = get_projects project_name = StringHelper.warnstrip!(name.to_s) project = projects.find { |current_project| current_project.name == project_name } return nil unless project project end |
#get_projects ⇒ Array<TestrailProject>
Get all projects on testrail
90 91 92 93 94 95 96 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 90 def get_projects projects = [] Testrail2.http_get('index.php?/api/v2/get_projects').each do |project| projects << TestrailProject.new.init_from_hash(project) end projects end |
#init_project_by_name(name) ⇒ TestrailProject
Initialize project by it’s name
111 112 113 114 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 111 def init_project_by_name(name) found_project = get_project_by_name name found_project.nil? ? create_new_project(name) : found_project end |
#project(name_or_id) ⇒ Object
region PROJECT
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/onlyoffice_testrail_wrapper/testrail.rb', line 77 def project(name_or_id) case name_or_id.class.to_s when 'Fixnum' get_project_by_id name_or_id when 'String' init_project_by_name name_or_id else raise 'Wrong argument. Must be name [String] or id [Integer]' end end |