Class: CemAcpt::Bolt::Tests::Test
- Inherits:
-
Object
- Object
- CemAcpt::Bolt::Tests::Test
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/bolt/tests.rb
Overview
Provides an interface for running tests against Bolt tasks
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
-
#command_result ⇒ Object
readonly
Returns the value of attribute command_result.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#add_group(group) ⇒ Object
Groups in this context refers to the acceptance test names.
-
#initialize(name, data, object, *groups) ⇒ Test
constructor
A new instance of Test.
- #inspect ⇒ Object
- #run ⇒ Object
- #to_s ⇒ Object
Methods included from Logging
current_log_config, #current_log_config, current_log_format, #current_log_format, #current_log_level, current_log_level, included, #logger, logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, #new_log_level, new_log_level, #new_logger, new_logger, verbose?, #verbose?
Constructor Details
#initialize(name, data, object, *groups) ⇒ Test
Returns a new instance of Test.
239 240 241 242 243 244 245 246 247 |
# File 'lib/cem_acpt/bolt/tests.rb', line 239 def initialize(name, data, object, *groups) @name = name @data = data.is_a?(Hash) ? TestData.new(**data) : TestData.new @object = object @groups = groups @command_result = nil @result = TestResults.new(name) @validation_results = {} end |
Instance Attribute Details
#command_result ⇒ Object (readonly)
Returns the value of attribute command_result.
237 238 239 |
# File 'lib/cem_acpt/bolt/tests.rb', line 237 def command_result @command_result end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
237 238 239 |
# File 'lib/cem_acpt/bolt/tests.rb', line 237 def data @data end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
237 238 239 |
# File 'lib/cem_acpt/bolt/tests.rb', line 237 def groups @groups end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
237 238 239 |
# File 'lib/cem_acpt/bolt/tests.rb', line 237 def name @name end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
237 238 239 |
# File 'lib/cem_acpt/bolt/tests.rb', line 237 def object @object end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
237 238 239 |
# File 'lib/cem_acpt/bolt/tests.rb', line 237 def result @result end |
Instance Method Details
#add_group(group) ⇒ Object
Groups in this context refers to the acceptance test names. Because the acceptance tests act like logical groups, we refer to them as groups here to avoid confusion with the Bolt tests.
251 252 253 |
# File 'lib/cem_acpt/bolt/tests.rb', line 251 def add_group(group) @groups << group unless @groups.include?(group) end |
#inspect ⇒ Object
267 268 269 |
# File 'lib/cem_acpt/bolt/tests.rb', line 267 def inspect to_s end |
#run ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/cem_acpt/bolt/tests.rb', line 255 def run logger.debug('CemAcpt::Bolt::Tests::Test') { "Running test #{name}" } @command_result = @object.run(**@data.params) validate! rescue StandardError => e new_wrapped_error("Error running test #{name}", e) end |
#to_s ⇒ Object
263 264 265 |
# File 'lib/cem_acpt/bolt/tests.rb', line 263 def to_s "#<#{self.class}:#{object_id.to_s(16)} #{name},#{object},#{groups.join(',')}>" end |