Class: RTrail::Suite
- Includes:
- Methods::Delete, Methods::Get, Methods::Update
- Defined in:
- lib/rtrail/suite.rb
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#add_section(fields = {}) ⇒ Object
Add a Section to the Suite.
- #cases(section_name_or_id = nil) ⇒ Object
- #section(section_name_or_id) ⇒ Object
-
#section_by_name(section_name) ⇒ Object
Return the first root-level Section with the given name, or raise RTrail::NotFound.
- #sections ⇒ Object
Methods included from Methods::Delete
Methods included from Methods::Update
Methods included from Methods::Get
Methods inherited from Entity
#add_entity, basename, client, #client, client=, #get_entities, #initialize, #method_missing
Methods included from Helpers
included, #is_id?, #path_with_params
Constructor Details
This class inherits a constructor from RTrail::Entity
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RTrail::Entity
Instance Method Details
#add_section(fields = {}) ⇒ Object
Add a Section to the Suite. Requires :name
56 57 58 59 60 61 |
# File 'lib/rtrail/suite.rb', line 56 def add_section(fields={}) section_data = fields.merge({ :suite_id => data.id, }) return add_entity(Section, data.project_id, section_data) end |
#cases(section_name_or_id = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rtrail/suite.rb', line 20 def cases(section_name_or_id=nil) if section_name_or_id section_id = section(section_name_or_id).id else section_id = nil end return get_entities( Case, data.project_id, :suite_id => data.id, :section_id => section_id ) end |
#section(section_name_or_id) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/rtrail/suite.rb', line 46 def section(section_name_or_id) if is_id?(section_name_or_id) return Section.get(section_name_or_id) else return section_by_name(section_name_or_id) end end |
#section_by_name(section_name) ⇒ Object
Return the first root-level Section with the given name, or raise RTrail::NotFound
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rtrail/suite.rb', line 35 def section_by_name(section_name) section = sections.find do |s| s.name == section_name and s.depth == 0 end if section.nil? raise RTrail::NotFound.new( "Section '#{section_name}' not found in Suite '#{data.name}'") end return section end |
#sections ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/rtrail/suite.rb', line 12 def sections return get_entities( Section, data.project_id, :suite_id => data.id ) end |