Module: Inferno::DSL::Runnable
- Included in:
- Entities::TestGroup, Entities::TestSuite
- Defined in:
- lib/inferno/dsl/runnable.rb
Overview
This module contains the DSL for defining child entities in the test definition framework.
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#suite_option_requirements ⇒ Object
readonly
Returns the value of attribute suite_option_requirements.
Instance Method Summary collapse
-
#block(&block) ⇒ Proc
(also: #run)
Set/Get the block that is executed when a runnable is run.
-
#description(new_description = nil) ⇒ String
Set/Get a runnable’s description.
-
#id(new_id = nil) ⇒ String, Symbol
Set/Get a runnable’s id.
-
#input_instructions(new_input_instructions = nil) ⇒ String
Set/Get a runnable’s input instructions.
-
#optional(optional = true) ⇒ void
Mark as optional.
-
#optional? ⇒ Boolean
The test or group is optional if true.
-
#required(required = true) ⇒ void
Mark as required.
-
#required? ⇒ Boolean
The test or group is required if true.
-
#required_suite_options(suite_option_requirements) ⇒ void
Set/get suite options required for this runnable to be executed.
-
#resume_test_route(method, path, tags: [], result: 'pass') { ... } ⇒ void
Create a route which will resume a test run when a request is received.
-
#route(method, path, handler) ⇒ void
Create a route to handle a request.
-
#short_description(new_short_description = nil) ⇒ String
Set/Get a runnable’s short one-sentence description.
-
#short_title(new_short_title = nil) ⇒ String
Set/Get a runnable’s short title.
-
#suite_endpoint(method, path, endpoint_class) ⇒ void
Create an endpoint to receive incoming requests during a Test Run.
-
#title(new_title = nil) ⇒ String
Set/Get a runnable’s title.
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
11 12 13 |
# File 'lib/inferno/dsl/runnable.rb', line 11 def parent @parent end |
#suite_option_requirements ⇒ Object (readonly)
Returns the value of attribute suite_option_requirements.
12 13 14 |
# File 'lib/inferno/dsl/runnable.rb', line 12 def suite_option_requirements @suite_option_requirements end |
Instance Method Details
#block(&block) ⇒ Proc Also known as: run
Set/Get the block that is executed when a runnable is run
298 299 300 301 302 |
# File 'lib/inferno/dsl/runnable.rb', line 298 def block(&block) return @block unless block_given? @block = block end |
#description(new_description = nil) ⇒ String
Set/Get a runnable’s description
230 231 232 233 234 |
# File 'lib/inferno/dsl/runnable.rb', line 230 def description(new_description = nil) return @description if new_description.nil? @description = format_markdown(new_description) end |
#id(new_id = nil) ⇒ String, Symbol
Set/Get a runnable’s id
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/inferno/dsl/runnable.rb', line 191 def id(new_id = nil) return @id if new_id.nil? && @id.present? prefix = if parent "#{parent.id}-" else '' end @base_id = new_id || @base_id || default_id @id = "#{prefix}#{@base_id}" end |
#input_instructions(new_input_instructions = nil) ⇒ String
Set/Get a runnable’s input instructions
250 251 252 253 254 |
# File 'lib/inferno/dsl/runnable.rb', line 250 def input_instructions(new_input_instructions = nil) return @input_instructions if new_input_instructions.nil? @input_instructions = format_markdown(new_input_instructions) end |
#optional(optional = true) ⇒ void
This method returns an undefined value.
Mark as optional. Tests are required by default.
260 261 262 |
# File 'lib/inferno/dsl/runnable.rb', line 260 def optional(optional = true) # rubocop:disable Style/OptionalBooleanParameter @optional = optional end |
#optional? ⇒ Boolean
The test or group is optional if true
278 279 280 |
# File 'lib/inferno/dsl/runnable.rb', line 278 def optional? !!@optional end |
#required(required = true) ⇒ void
This method returns an undefined value.
Mark as required
Tests are required by default. This method is provided to make an existing optional test required.
271 272 273 |
# File 'lib/inferno/dsl/runnable.rb', line 271 def required(required = true) # rubocop:disable Style/OptionalBooleanParameter @optional = !required end |
#required? ⇒ Boolean
The test or group is required if true
285 286 287 |
# File 'lib/inferno/dsl/runnable.rb', line 285 def required? !optional? end |
#required_suite_options(suite_option_requirements) ⇒ void
This method returns an undefined value.
Set/get suite options required for this runnable to be executed.
443 444 445 446 447 448 |
# File 'lib/inferno/dsl/runnable.rb', line 443 def (suite_option_requirements) @suite_option_requirements = suite_option_requirements.map do |key, value| DSL::SuiteOption.new(id: key, value:) end end |
#resume_test_route(method, path, tags: [], result: 'pass') { ... } ⇒ void
This method returns an undefined value.
Create a route which will resume a test run when a request is received
354 355 356 357 358 359 360 361 362 |
# File 'lib/inferno/dsl/runnable.rb', line 354 def resume_test_route(method, path, tags: [], result: 'pass', &block) route_class = Class.new(ResumeTestRoute) do |klass| klass.singleton_class.instance_variable_set(:@test_run_identifier_block, block) klass.singleton_class.instance_variable_set(:@tags, ) klass.singleton_class.instance_variable_set(:@result, result) end route(method, path, route_class) end |
#route(method, path, handler) ⇒ void
This method returns an undefined value.
Create a route to handle a request
396 397 398 |
# File 'lib/inferno/dsl/runnable.rb', line 396 def route(method, path, handler) Inferno.routes << { method:, path:, handler:, suite: } end |
#short_description(new_short_description = nil) ⇒ String
Set/Get a runnable’s short one-sentence description
240 241 242 243 244 |
# File 'lib/inferno/dsl/runnable.rb', line 240 def short_description(new_short_description = nil) return @short_description if new_short_description.nil? @short_description = format_markdown(new_short_description) end |
#short_title(new_short_title = nil) ⇒ String
Set/Get a runnable’s short title
220 221 222 223 224 |
# File 'lib/inferno/dsl/runnable.rb', line 220 def short_title(new_short_title = nil) return @short_title if new_short_title.nil? @short_title = new_short_title end |
#suite_endpoint(method, path, endpoint_class) ⇒ void
This method returns an undefined value.
Create an endpoint to receive incoming requests during a Test Run.
378 379 380 |
# File 'lib/inferno/dsl/runnable.rb', line 378 def suite_endpoint(method, path, endpoint_class) route(method, path, endpoint_class) end |
#title(new_title = nil) ⇒ String
Set/Get a runnable’s title
210 211 212 213 214 |
# File 'lib/inferno/dsl/runnable.rb', line 210 def title(new_title = nil) return @title if new_title.nil? @title = new_title end |