Module: Inferno::DSL::Configurable

Defined in:
lib/inferno/dsl/configurable.rb

Overview

This module contains the DSL for managing runnable configuration. Runnable configuration provides a way to modify test behavior at boot time.

The main features enabled by configuration are: - Modifying the properties of a runnable’s inputs. This could include locking a particular input, making a particular input optional/required, or changing an input’s value. - Renaming an input/output/request to avoid name collisions when a test suite uses the same test multiple times. - Tests can define custom configuration options to enable different - testing behavior.

Examples:

test do
  id :json_request_test

  input :url
  output :response_body
  makes_request :json_request

  run do
    if config.options[:include_content_type]
      get url, headers: { 'Content-Type' => 'application/json' }
    else
      get url
    end

    assert_response_status(200)
    output response_body: request.response_body
    assert_valid_json
  end
end

group do
  test from :json_request_test do
    id :json_request_without_content_type

    config(
      inputs: {
        url: { name: :url_without_content_type }
      },
      outputs: {
        response_body: { name: :response_body_without_content_type }
      },
      requests: {
        json_request: { name: :json_request_without_content_type }
      }
    )
  end

  test from :json_request_test do
    id :json_request_with_content_type

    config(
      options: {
        include_content_type: true
      },
      inputs: {
        url: { name: :url_with_content_type }
      },
      outputs: {
        response_body: { name: :response_body_with_content_type }
      },
      requests: {
        json_request: { name: :json_request_with_content_type }
      }
    )
  end
end

Defined Under Namespace

Classes: Configuration

Instance Method Summary collapse

Instance Method Details

#config(new_configuration = {}) ⇒ Object

Define/update/get the configuration for a runnable. This configuration will be applied to the runnable and all of its children.

Parameters:

  • new_configuration (Hash) (defaults to: {})


84
85
86
87
88
89
90
91
92
93
94
# File 'lib/inferno/dsl/configurable.rb', line 84

def config(new_configuration = {})
  @config ||= Configuration.new

  return @config if new_configuration.blank?

  @config.apply(new_configuration)

  all_children.each { |child| child.config(new_configuration) }

  @config
end