class Result
This is an extension of Result
class
This is an extension of Result
class
This is an extension of Result
class
This object contains data returned by remote/local execution
-
initialize
-
alterations
-
content
-
debug
-
ok?
-
reset
-
restore
-
value
Attributes
content[R]
exitstatus[RW]
Public Class Methods
new()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 20 def initialize reset end
Public Instance Methods
alterations()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 24 def alterations @alterations.join(' & ') end
contain?(value)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_array.rb, line 28 def contain?(value) @expected = "Contain <#{value}> value" @content.contain? value end
content=(content)
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 28 def content=(content) @content_backup = content.clone @content = content.clone end
count()
click to toggle source
# File lib/teuton/case_manager/case/result/ext_array.rb, line 5 def count @alterations << 'count' if @content.class == Array @content = [@content.count] self elsif @content.nil? @content = ['0'] else @content = [@content.to_i.to_s] end self end
debug()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 42 def debug print "\n" + '*' * 20 print " [DEBUG] count=#{@content.count} " puts '*' * 20 @content.each_with_index do |item, index| puts format('%2d: %s', index, item) end puts '*' * 57 end
empty()
click to toggle source
# File lib/teuton/case_manager/case/result/ext_array.rb, line 33 def empty @expected = 'Empty!' @content.empty end
Also aliased as: empty?
eq(input)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 5 def eq(input) @expected = input case input.class.to_s when 'Fixnum' value = @content[0].to_i puts '[WARN] Fixnum class is deprecated!' puts ' Upgrade your Ruby version.' when 'Float' value = @content[0].to_f when 'Integer' value = @content[0].to_i when 'String' value = @content[0].to_s else value = @content[0] end value == input end
expected()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 52 def expected @expected.to_s end
find(filter)
click to toggle source
TODO: Error line 102 undefined include? method for 0 Fixnum…
# File lib/teuton/case_manager/case/result/ext_filter.rb, line 6 def find(filter) @alterations << "find(#{filter})" case filter.class.to_s when 'Array' find_when_array(filter) when 'String' || 'Integer' @content.select! { |i| i.include?(filter.to_s) } when 'Regexp' @content.select! { |i| filter.match(i) } end self end
ge(input)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 50 def ge(input) @expected = "Greater or equal to #{input}" return false if @content.nil? || @content[0].nil? value = @content[0] case input.class.to_s when 'Fixnum' value = @content[0].to_i puts '[WARN] Fixnum class is deprecated!' puts ' Upgrade your Ruby version.' when 'Float' value = @content[0].to_f when 'Integer' value = @content[0].to_i end value >= input end
Also aliased as: greater_or_equal, greater_or_equal?
gt(input)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 70 def gt(input) @expected = "Greater than #{input}" return false if @content.nil? || @content[0].nil? value = @content[0] case input.class.to_s when 'Fixnum' value = @content[0].to_i puts '[WARN] Fixnum class is deprecated!' puts ' Upgrade your Ruby version.' when 'Float' value = @content[0].to_f when 'Integer' value = @content[0].to_i end value > input end
Also aliased as: greater, greater_than
include?(value)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_array.rb, line 18 def include?(value) @expected = "Include <#{value}> value" @content[0].include?(value) end
le(input)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 90 def le(input) @expected = "Lesser or equal to #{input}" return false if @content.nil? || @content[0].nil? value = @content[0] case input.class.to_s when 'Fixnum' value = @content[0].to_i puts '[WARN] Fixnum class is deprecated!' puts ' Upgrade your Ruby version.' when 'Float' value = @content[0].to_f when 'Integer' value = @content[0].to_i end value <= input end
Also aliased as: lesser_or_equal, lesser_or_equal?
lt(input)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 111 def lt(input) @expected = "Lesser than #{input}" return false if @content.nil? || @content[0].nil? value = @content[0] case input.class.to_s when 'Fixnum' value = @content[0].to_i puts '[WARN] Fixnum class is deprecated!' puts ' Upgrade your Ruby version.' when 'Float' value = @content[0].to_f when 'Integer' value = @content[0].to_i end value < input end
near_to?(input)
click to toggle source
Return 'true' if the parameter value is near to the target value. To get this we consider a 10% desviation or less, as an acceptable result.
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 134 def near_to?(input) @expected = "Is near to #{input}" return false if @content.nil? target = @content[0].to_f desv = (target * 10.0) / 100.0 return true if (target - input.to_f).abs.to_f <= desv false end
neq(external)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_compare.rb, line 29 def neq(external) @expected = "Not equal to #{external}" case external.class.to_s when 'Fixnum' internal = @content[0].to_i puts '[WARN] Fixnum class is deprecated!' puts ' Upgrade your Ruby version.' when 'Float' internal = @content[0].to_f when 'Integer' internal = @content[0].to_i else internal = @content[0] end internal != external end
not_find(p_filter)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_filter.rb, line 22 def not_find(p_filter) @alterations << "not_find(#{p_filter})" return self if @content.size.zero? @content.reject! { |i| i.include?(p_filter) } self end
Also aliased as: grep_v
not_include?(value)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_array.rb, line 23 def not_include?(value) @expected = "Not include <#{value}> value" !@content[0].include?(value) end
ok?()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 56 def ok? return false if @exitstatus.nil? @exitstatus.zero? end
reset()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 33 def reset @content_backup = [] @content = [] @exitstatus = nil @value = nil @expected = nil @alterations = [] end
restore()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 62 def restore temp = @content_backup.clone reset @content_backup = temp @content = temp.clone end
Also aliased as: restore!
since(filter)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_filter.rb, line 31 def since(filter) @alterations << "since(#{filter})" return self if @content.size.zero? if filter.class == String flag = false @content.select! do |i| flag = true if i.include?(filter.to_s) flag end end self end
until(filter)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_filter.rb, line 45 def until(filter) @alterations << "until(#{filter})" return self if @content.size.zero? if filter.class == String flag = true @content.select! do |i| flag = false if i.include?(filter.to_s) flag end end self end
value()
click to toggle source
# File lib/teuton/case_manager/case/result/result.rb, line 70 def value @content[0] end
Private Instance Methods
find_when_array(filter)
click to toggle source
# File lib/teuton/case_manager/case/result/ext_filter.rb, line 61 def find_when_array(filter) @content.select! do |line| flag = false filter.each { |i| flag ||= line.include?(i) } flag end end