blob: 15d4112d347d0473d49b7ba7cee836078664b265 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
module QA
module Runtime
##
# Singleton approach to global test scenario arguments.
#
module Scenario
extend self
def attributes
@attributes ||= {}
end
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
def method_missing(name, *)
raise ArgumentError, "Scenario attribute `#{name}` not defined!"
end
end
end
end
|