Class: RoxClient::TestResult

Inherits:
Object
  • Object
show all
Defined in:
lib/rox-client-ruby/test_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, options = {}) ⇒ TestResult



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rox-client-ruby/test_result.rb', line 6

def initialize project, options = {}

  @key = options[:key]
  @name = options[:name]

  @category = project.category || options[:category]
  @tags = (wrap(project.tags) + wrap(options[:tags])).compact.collect(&:to_s).uniq
  @tickets = (wrap(project.tickets) + wrap(options[:tickets])).compact.collect(&:to_s).uniq

  @grouped = !!options[:grouped]

  @passed = !!options[:passed]
  @duration = options[:duration]
  @message = options[:message]
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def category
  @category
end

#durationObject (readonly)

Returns the value of attribute duration.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def duration
  @duration
end

#keyObject (readonly)

Returns the value of attribute key.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def key
  @key
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def message
  @message
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def name
  @name
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def tags
  @tags
end

#ticketsObject (readonly)

Returns the value of attribute tickets.



4
5
6
# File 'lib/rox-client-ruby/test_result.rb', line 4

def tickets
  @tickets
end

Instance Method Details

#grouped?Boolean



26
27
28
# File 'lib/rox-client-ruby/test_result.rb', line 26

def grouped?
  @grouped
end

#passed?Boolean



22
23
24
# File 'lib/rox-client-ruby/test_result.rb', line 22

def passed?
  @passed
end

#to_h(options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rox-client-ruby/test_result.rb', line 36

def to_h options = {}
  {
    'k' => @key,
    'p' => @passed,
    'd' => @duration
  }.tap do |h|

    h['m'] = @message if @message

    cache = options[:cache]
    first = !cache || !cache.known?(self)
    stale = !first && cache.stale?(self)
    h['n'] = @name if stale or first
    h['c'] = @category if stale or (first and @category)
    h['g'] = @tags if stale or (first and !@tags.empty?)
    h['t'] = @tickets if stale or (first and !@tickets.empty?)
  end
end

#update(options = {}) ⇒ Object



30
31
32
33
34
# File 'lib/rox-client-ruby/test_result.rb', line 30

def update options = {}
  @passed &&= !!options[:passed]
  @duration += options[:duration]
  @message = [ @message, options[:message] ].select{ |m| m }.join("\n\n") if options[:message]
end