Class: CemAcpt::Bolt::Tests::TestResults

Inherits:
Object
  • Object
show all
Defined in:
lib/cem_acpt/bolt/tests.rb

Overview

Contains the results of running a Bolt task test

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(test_name, results = []) ⇒ TestResults

Returns a new instance of TestResults.



183
184
185
186
# File 'lib/cem_acpt/bolt/tests.rb', line 183

def initialize(test_name, results = [])
  @test_name = test_name
  @results = results
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **kwargs, &block) ⇒ Object



216
217
218
219
220
221
222
# File 'lib/cem_acpt/bolt/tests.rb', line 216

def method_missing(method_name, *args, **kwargs, &block)
  if @results.respond_to?(method_name)
    @results.send(method_name, *args, **kwargs, &block)
  else
    super
  end
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



181
182
183
# File 'lib/cem_acpt/bolt/tests.rb', line 181

def results
  @results
end

#test_nameObject (readonly)

Returns the value of attribute test_name.



181
182
183
# File 'lib/cem_acpt/bolt/tests.rb', line 181

def test_name
  @test_name
end

Instance Method Details

#actionObject



196
197
198
# File 'lib/cem_acpt/bolt/tests.rb', line 196

def action
  @action ||= @results.empty? ? 'unknown' : @results.first.action
end

#inspectObject



228
229
230
# File 'lib/cem_acpt/bolt/tests.rb', line 228

def inspect
  "#<#{self.class}:#{object_id.to_s(16)} with #{results.count} result(s)>"
end

#objectObject



204
205
206
# File 'lib/cem_acpt/bolt/tests.rb', line 204

def object
  @object ||= @results.empty? ? 'unknown' : @results.first.object
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


224
225
226
# File 'lib/cem_acpt/bolt/tests.rb', line 224

def respond_to_missing?(method_name, include_private = false)
  @results.respond_to?(method_name, include_private) || super
end

#statusObject



192
193
194
# File 'lib/cem_acpt/bolt/tests.rb', line 192

def status
  @status ||= success? ? 'success' : 'failure'
end

#success?Boolean

Returns:

  • (Boolean)


188
189
190
# File 'lib/cem_acpt/bolt/tests.rb', line 188

def success?
  @results.all? { |r| r.success? }
end

#targetObject



200
201
202
# File 'lib/cem_acpt/bolt/tests.rb', line 200

def target
  @target ||= @results.empty? ? 'unknown' : @results.first.target
end

#to_hObject



208
209
210
211
212
213
214
# File 'lib/cem_acpt/bolt/tests.rb', line 208

def to_h
  {
    test_name: test_name,
    success: success?,
    results: @results.map(&:to_h),
  }
end