Class: TestRail::Section

Inherits:
Object
  • Object
show all
Includes:
InitializeWithApi
Defined in:
lib/test_rail/section.rb

Instance Method Summary collapse

Methods included from InitializeWithApi

#initialize

Instance Method Details

#add_section(args) ⇒ Object

suite.add_section( :name => ‘Section name )



47
48
49
# File 'lib/test_rail/section.rb', line 47

def add_section( args )
  @api.add_section( :project_id => project_id, :parent_id => @id, :suite_id => @suite_id, :name =>  args[:name] )
end

#find_or_create_section(args) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/test_rail/section.rb', line 56

def find_or_create_section( args )
  name = args[:name] or raise "Need to provide the sub-section name (:name => 'subsection01')"
  section = self.find_section( args )
  if section.nil?
    section = add_section( args )
  end
  section
end

#find_or_create_test_case(args) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/test_rail/section.rb', line 37

def find_or_create_test_case( args )
  title = args[:title] or raise "Need to provide the title of a test case"
  test_case = self.find_test_case( args )
  if test_case.nil?
    test_case = new_test_case( args )
  end
  test_case
end

#find_section(args) ⇒ Object



51
52
53
54
# File 'lib/test_rail/section.rb', line 51

def find_section( args )
  name = args[:name] or raise "Need to provide the sub-section name (:name => 'subsection01')"
  sub_sections.select{ |s| s.name == name }.first
end

#find_test_case(args) ⇒ Object



32
33
34
35
# File 'lib/test_rail/section.rb', line 32

def find_test_case( args )
  title = args[:title] or raise "Need to provide the title of a test case"
  test_cases.select{ |c| c.title == title }.first
end

#new_test_case(args) ⇒ Object



28
29
30
# File 'lib/test_rail/section.rb', line 28

def new_test_case(args)
  @api.add_case(args.merge({:section_id => @id }))
end

#sub_sectionsObject

Get a list of sub-sections



18
19
20
21
# File 'lib/test_rail/section.rb', line 18

def sub_sections
  sections = @api.get_sections( :project_id => @project_id, :suite_id => @suite_id )
  sections.reject{ |s| s.parent_id != @id }
end

#test_casesObject

Get a list of test-cases



24
25
26
# File 'lib/test_rail/section.rb', line 24

def test_cases
  @api.get_cases( :project_id => @project_id, :suite_id => @suite_id, :section_id => @id )
end

#updateObject



13
14
15
# File 'lib/test_rail/section.rb', line 13

def update
  @api.update_section( :section_id => @id, :name => name, :project_id => @project_id, :suite_id => @suite_id, :parent_id => @id)
end