Class: Rutema::Model::Run

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/rutemaweb/model.rb

Overview

Extensions of Run to accomodate specific view requirements for rutemaweb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_on_page(page_num, page_size, conditions = nil) ⇒ Object

The view wants to display runs grouped into pages, where each page shows page_size runs at a time. This method returns the runs on page page_num (starting at zero).



15
16
17
18
19
20
21
# File 'lib/rutemaweb/model.rb', line 15

def self.find_on_page(page_num, page_size,conditions=nil) 
  find(:all, 
  :order => "id DESC", 
  :limit => page_size, 
  :conditions=>conditions,
  :offset => page_num*page_size) 
end

Instance Method Details

#config_fileObject



46
47
48
49
# File 'lib/rutemaweb/model.rb', line 46

def config_file
  return nil if self.context.is_a?(OpenStruct)
  return context[:config_file]
end

#number_of_failedObject

number of unsuccessful scenarios (does not count setup or teardown scripts)



39
40
41
# File 'lib/rutemaweb/model.rb', line 39

def number_of_failed
  self.scenarios.select{|sc| !sc.success? && sc.is_test? }.size
end

#number_of_testsObject

returns the number of actual tests (so, don’t take into account setup or teardown tests)



43
44
45
# File 'lib/rutemaweb/model.rb', line 43

def number_of_tests
   self.scenarios.select{|sc| sc.is_test? }.size
end

#statusObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rutemaweb/model.rb', line 23

def status
  st=:success
  st=:warning if scenarios.empty?
  self.scenarios.each do |sc|
    case sc.status
    when "warning" || "not_executed"
      st=:warning unless st==:error
      break
    when "error"
      st=:error
      break
    end
  end
  return st
end