Class: RTrail::Project
- Includes:
- Methods::Delete, Methods::Get, Methods::Update
- Defined in:
- lib/rtrail/project.rb
Instance Attribute Summary
Attributes inherited from Entity
Class Method Summary collapse
Instance Method Summary collapse
-
#add_run(suite_name_or_id, fields = {}) ⇒ Object
Create a new Run in the given Suite in this project.
-
#add_suite(fields = {}) ⇒ Object
Add a new Suite to the Project.
- #plans ⇒ Object
-
#run(suite_name_or_id, run_name) ⇒ Object
Return an existing run with the given name, or create and return a new run.
- #runs ⇒ Object
-
#suite(suite_name_or_id) ⇒ Object
Return a suite with the given name or id in the current project.
-
#suite_by_name(suite_name) ⇒ Object
Return a suite with the given name in the current project.
- #suite_id(suite_name_or_id) ⇒ Object
- #suites ⇒ 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
Class Method Details
.all ⇒ Object
13 14 15 16 17 |
# File 'lib/rtrail/project.rb', line 13 def self.all return client.get("get_projects").map do |project| self.new(project) end end |
.by_name(project_name) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/rtrail/project.rb', line 19 def self.by_name(project_name) result = Project.all.find do |project| project.name == project_name end if result.nil? raise RTrail::NotFound.new("Project '#{project_name}' not found in TestRail") end return self.new(result) end |
Instance Method Details
#add_run(suite_name_or_id, fields = {}) ⇒ Object
Create a new Run in the given Suite in this project.
78 79 80 81 82 83 |
# File 'lib/rtrail/project.rb', line 78 def add_run(suite_name_or_id, fields={}) run_data = fields.merge({ :suite_id => suite_id(suite_name_or_id), }) return add_entity(Run, data.id, run_data) end |
#add_suite(fields = {}) ⇒ Object
Add a new Suite to the Project. Requires :name
87 88 89 |
# File 'lib/rtrail/project.rb', line 87 def add_suite(fields={}) return add_entity(Suite, data.id, fields) end |
#plans ⇒ Object
54 55 56 |
# File 'lib/rtrail/project.rb', line 54 def plans return get_entities(Plan, data.id) end |
#run(suite_name_or_id, run_name) ⇒ Object
Return an existing run with the given name, or create and return a new run.
68 69 70 71 72 73 74 75 |
# File 'lib/rtrail/project.rb', line 68 def run(suite_name_or_id, run_name) existing = runs.find {|r| r.name == run_name} if existing return existing else return add_run(suite_name_or_id, :name => run_name) end end |
#runs ⇒ Object
58 59 60 |
# File 'lib/rtrail/project.rb', line 58 def runs return get_entities(Run, data.id) end |
#suite(suite_name_or_id) ⇒ Object
Return a suite with the given name or id in the current project.
42 43 44 45 46 47 48 |
# File 'lib/rtrail/project.rb', line 42 def suite(suite_name_or_id) if is_id?(suite_name_or_id) return Suite.get(suite_name_or_id) else return suite_by_name(suite_name_or_id) end end |
#suite_by_name(suite_name) ⇒ Object
Return a suite with the given name in the current project.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rtrail/project.rb', line 30 def suite_by_name(suite_name) suite = suites.find do |s| s.name == suite_name end if suite.nil? raise RTrail::NotFound.new( "Suite '#{suite_name}' not found in project '#{self.data.name}'") end return suite end |
#suite_id(suite_name_or_id) ⇒ Object
50 51 52 |
# File 'lib/rtrail/project.rb', line 50 def suite_id(suite_name_or_id) return self.suite(suite_name_or_id).id end |
#suites ⇒ Object
62 63 64 |
# File 'lib/rtrail/project.rb', line 62 def suites return get_entities(Suite, data.id) end |