class RRRSpec::Trial
Attributes
key[R]
Public Class Methods
create(task, slave)
click to toggle source
Public: Create a new trial. This method will call Task#add_trial
and Slave#add_trial
.
# File lib/rrrspec/redis_models.rb, line 700 def self.create(task, slave) trial_key = RRRSpec.make_key( task.key, 'trial', UUIDTools::UUID.timestamp_create ) RRRSpec.redis.hmset( trial_key, 'task', task.key, 'slave', slave.key, ) trial = new(trial_key) task.add_trial(trial) slave.add_trial(trial) return trial end
new(trial_key)
click to toggle source
# File lib/rrrspec/redis_models.rb, line 694 def initialize(trial_key) @key = trial_key end
Public Instance Methods
expire(sec)
click to toggle source
failed()
click to toggle source
Public: Returns the failed examples
# File lib/rrrspec/redis_models.rb, line 800 def failed v = RRRSpec.redis.hget(key, 'failed') v.present? ? v.to_i : nil end
finish(status, stdout, stderr, passed, pending, failed)
click to toggle source
Public: Finish the trial status should be one of [“passed”, “pending”, “failed”, “error”]. stdout and stderr should be string or nil. passed, pending and failed is the count of examplegroups and should be either nil or numbers.
# File lib/rrrspec/redis_models.rb, line 752 def finish(status, stdout, stderr, passed, pending, failed) RRRSpec.redis.hmset( key, 'finished_at', Time.zone.now.to_s, 'status', status, 'stdout', stdout, 'stderr', stderr, 'passed', passed, 'pending', pending, 'failed', failed ) end
finished_at()
click to toggle source
Public: Returns the finished_at
# File lib/rrrspec/redis_models.rb, line 772 def finished_at v = RRRSpec.redis.hget(key, 'finished_at') v.present? ? Time.zone.parse(v) : nil end
passed()
click to toggle source
Public: Returns the passed examples
# File lib/rrrspec/redis_models.rb, line 788 def passed v = RRRSpec.redis.hget(key, 'passed') v.present? ? v.to_i : nil end
pending()
click to toggle source
Public: Returns the pending examples
# File lib/rrrspec/redis_models.rb, line 794 def pending v = RRRSpec.redis.hget(key, 'pending') v.present? ? v.to_i : nil end
slave()
click to toggle source
Public: The slave worked for this.
Returns a Slave
# File lib/rrrspec/redis_models.rb, line 728 def slave Slave.new(RRRSpec.redis.hget(key, 'slave')) end
start()
click to toggle source
Public: Set started_at
time.
# File lib/rrrspec/redis_models.rb, line 743 def start RRRSpec.redis.hset(key, 'started_at', Time.zone.now.to_s) end
started_at()
click to toggle source
Public: Returns the started_at
# File lib/rrrspec/redis_models.rb, line 766 def started_at v = RRRSpec.redis.hget(key, 'started_at') v.present? ? Time.zone.parse(v) : nil end
status()
click to toggle source
Public: Current status
Returns either nil, “passed”, “pending”, “failed” or “error”
# File lib/rrrspec/redis_models.rb, line 738 def status RRRSpec.redis.hget(key, 'status') end
stderr()
click to toggle source
Public: Returns the stderr
# File lib/rrrspec/redis_models.rb, line 783 def stderr RRRSpec.redis.hget(key, 'stderr') end
stdout()
click to toggle source
Public: Returns the stdout
# File lib/rrrspec/redis_models.rb, line 778 def stdout RRRSpec.redis.hget(key, 'stdout') end
task()
click to toggle source
Public: Tried task
Returns a Task
# File lib/rrrspec/redis_models.rb, line 721 def task Task.new(RRRSpec.redis.hget(key, 'task')) end
to_h()
click to toggle source
¶ ↑
Serialize
# File lib/rrrspec/redis_models.rb, line 808 def to_h h = RRRSpec.redis.hgetall(key) h['key'] = key h['task'] = { 'key' => h['task'] } h['slave'] = { 'key' => h['slave'] } RRRSpec.convert_if_present(h, 'started_at') { |v| Time.zone.parse(v) } RRRSpec.convert_if_present(h, 'finished_at') { |v| Time.zone.parse(v) } RRRSpec.convert_if_present(h, 'passed') { |v| v.to_i } RRRSpec.convert_if_present(h, 'pending') { |v| v.to_i } RRRSpec.convert_if_present(h, 'failed') { |v| v.to_i } h end
to_json(options=nil)
click to toggle source
# File lib/rrrspec/redis_models.rb, line 821 def to_json(options=nil) to_h.to_json(options) end