Class: RTrail::API

Inherits:
Object
  • Object
show all
Defined in:
lib/rtrail/api.rb

Overview

High-level API for TestRail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, user, password) ⇒ API

Returns a new instance of API.



8
9
10
11
12
13
14
15
# File 'lib/rtrail/api.rb', line 8

def initialize(hostname, user, password)
  url = hostname.gsub(/\/$/, '') + '/index.php?/api/v2/'

  @client = RTrail::Client.new(url, user, password)

  # FIXME: This is a bit hinky, but works well
  RTrail::Entity.client = @client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



16
17
18
# File 'lib/rtrail/api.rb', line 16

def client
  @client
end

Instance Method Details

#cases(project_name, suite_name) ⇒ Object



36
37
38
# File 'lib/rtrail/api.rb', line 36

def cases(project_name, suite_name)
  return suite(project_name, suite_name).cases
end

#project(project_name) ⇒ Object



24
25
26
# File 'lib/rtrail/api.rb', line 24

def project(project_name)
  return Project.by_name(project_name)
end

#projectsObject

Convenience methods for commonly-accessed entities



20
21
22
# File 'lib/rtrail/api.rb', line 20

def projects
  return Project.all
end

#runs(project_name) ⇒ Object



32
33
34
# File 'lib/rtrail/api.rb', line 32

def runs(project_name)
  return project(project_name).runs
end

#suite(project_name, suite_name) ⇒ Object



28
29
30
# File 'lib/rtrail/api.rb', line 28

def suite(project_name, suite_name)
  return Project.by_name(project_name).suite_by_name(suite_name)
end