Class: Spassky::Server::TestRun
- Inherits:
-
Object
- Object
- Spassky::Server::TestRun
- Defined in:
- lib/spassky/server/test_run.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .create(options) ⇒ Object
- .find(id) ⇒ Object
- .find_next_test_to_run_by_device_id(device_id) ⇒ Object
Instance Method Summary collapse
-
#initialize(options) ⇒ TestRun
constructor
A new instance of TestRun.
- #result ⇒ Object
- #run_by_device_id?(device_id) ⇒ Boolean
- #save_result_for_device(options) ⇒ Object
- #update_connected_devices(device_ids) ⇒ Object
Constructor Details
#initialize(options) ⇒ TestRun
Returns a new instance of TestRun.
7 8 9 10 11 12 13 14 15 |
# File 'lib/spassky/server/test_run.rb', line 7 def initialize() @name = [:name] @contents = [:contents] @status_by_device_id = {} @message_by_device_id = {} ([:devices] || []).each do |device| @status_by_device_id[device] = "in progress" end end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
5 6 7 |
# File 'lib/spassky/server/test_run.rb', line 5 def contents @contents end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/spassky/server/test_run.rb', line 5 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/spassky/server/test_run.rb', line 5 def name @name end |
Class Method Details
.create(options) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/spassky/server/test_run.rb', line 41 def self.create() new_test_run = TestRun.new() new_test_run.id = test_runs.size test_runs << new_test_run new_test_run end |
.find(id) ⇒ Object
48 49 50 |
# File 'lib/spassky/server/test_run.rb', line 48 def self.find(id) test_runs.find { |test_run| test_run.id.to_s == id.to_s } end |
.find_next_test_to_run_by_device_id(device_id) ⇒ Object
52 53 54 |
# File 'lib/spassky/server/test_run.rb', line 52 def self.find_next_test_to_run_by_device_id(device_id) test_runs.find { |test_run| test_run.run_by_device_id?(device_id) == false } end |
Instance Method Details
#result ⇒ Object
35 36 37 38 39 |
# File 'lib/spassky/server/test_run.rb', line 35 def result Spassky::TestSuiteResult.new(@status_by_device_id.map { |device_id, status| Spassky::DeviceTestStatus.new(:device_id => device_id, :status => status, :message => @message_by_device_id[device_id], :test_name => @name) }) end |
#run_by_device_id?(device_id) ⇒ Boolean
17 18 19 |
# File 'lib/spassky/server/test_run.rb', line 17 def run_by_device_id?(device_id) @status_by_device_id[device_id] != "in progress" end |
#save_result_for_device(options) ⇒ Object
21 22 23 24 25 |
# File 'lib/spassky/server/test_run.rb', line 21 def save_result_for_device() validate_status [:status] @status_by_device_id[[:device_identifier]] = [:status] @message_by_device_id[[:device_identifier]] = [:message] end |
#update_connected_devices(device_ids) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/spassky/server/test_run.rb', line 27 def update_connected_devices(device_ids) @status_by_device_id.each do |device_id, status| if !device_ids.include?(device_id) && status == "in progress" @status_by_device_id[device_id] = "timed out" end end end |