Module: OnlyofficeTestrailWrapper::TestrailProjectSuiteMethods

Extended by:
Gem::Deprecate
Included in:
TestrailProject
Defined in:
lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb

Overview

Methods to perform operations on Suites

Instance Method Summary collapse

Instance Method Details

#create_new_suite(name, description = '') ⇒ TestrailSuite

Create new test suite in project

Parameters:

  • name (String)

    of suite

  • description (String) (defaults to: '')

    description of suite

Returns:



62
63
64
65
66
67
68
69
70
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 62

def create_new_suite(name, description = '')
  new_suite = TestrailSuite.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_suite/#{@id}",
                                                                   name: StringHelper.warnstrip!(name),
                                                                   description: description))
  new_suite.instance_variable_set(:@project, self)
  OnlyofficeLoggerHelper.log "Created new suite: #{new_suite.name}"
  @suites_names[new_suite.name] = new_suite.id
  new_suite
end

#get_suite_by_id(id) ⇒ Object



43
44
45
46
47
48
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 43

def get_suite_by_id(id)
  suite = TestrailSuite.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_suite/#{id}"))
  suite.instance_variable_set(:@project, self)
  OnlyofficeLoggerHelper.log("Initialized suite: #{suite.name}")
  suite
end

#get_suite_by_name(name) ⇒ TestrailSuite?

Get Test Suite by it’s name

Parameters:

  • name (String)

    name of test suite

Returns:



38
39
40
41
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 38

def get_suite_by_name(name)
  get_suites if @suites_names.empty?
  @suites_names[StringHelper.warnstrip!(name)].nil? ? nil : get_suite_by_id(@suites_names[name])
end

#get_suitesArray<Hash>

Get all test suites of project

Returns:

  • (Array<Hash>)

    array with suites data in hash



19
20
21
22
23
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 19

def get_suites
  suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
  @suites_names = name_id_pairs(suites) if @suites_names.empty?
  suites
end

#init_suite_by_name(name) ⇒ TestrailSuite

Init suite by it’s name

Parameters:

  • name (String)

    name of suit

Returns:



53
54
55
56
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 53

def init_suite_by_name(name)
  found_suite = get_suite_by_name name
  found_suite.nil? ? create_new_suite(name) : found_suite
end

#suite(name_or_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 6

def suite(name_or_id)
  case name_or_id.class.to_s
  when 'Fixnum', 'Integer'
    get_suite_by_id name_or_id
  when 'String'
    init_suite_by_name name_or_id
  else
    raise 'Wrong argument. Must be name [String] or id [Integer]'
  end
end

#suitesArray<TestrailSuite>

Get all test suites of project as objects

Returns:



30
31
32
33
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_suite_methods.rb', line 30

def suites
  suites = Testrail2.http_get("index.php?/api/v2/get_suites/#{@id}")
  suites.map { |suite| TestrailSuite.new.init_from_hash(suite) }
end