Module: Gitlab::QA::Runtime::Scenario

Extended by:
Scenario
Included in:
Scenario
Defined in:
lib/gitlab/qa/runtime/scenario.rb

Overview

Singleton approach to global test scenario arguments.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

rubocop:disable Style/MethodMissing

Raises:

  • (ArgumentError)


29
30
31
# File 'lib/gitlab/qa/runtime/scenario.rb', line 29

def method_missing(name, *)
  raise ArgumentError, "Scenario attribute `#{name}` not defined!"
end

Instance Method Details

#attributesObject



12
13
14
# File 'lib/gitlab/qa/runtime/scenario.rb', line 12

def attributes
  @attributes ||= {}
end

#define(attribute, value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/qa/runtime/scenario.rb', line 16

def define(attribute, value)
  attributes.store(attribute.to_sym, value)

  define_singleton_method(attribute) do
    attributes[attribute.to_sym].tap do |value|
      if value.to_s.empty?
        raise ArgumentError, "Empty `#{attribute}` attribute!"
      end
    end
  end
end