Skip to content

Commit 5699cc2

Browse files
committed
[API] Test Runner: Consider hashes as set variable values
1 parent fee1f8a commit 5699cc2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api-spec-testing/test_file/action.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def execute(client, test = nil)
8989
when 'catch', 'warnings', 'allowed_warnings', 'allowed_warnings_regex'
9090
client
9191
when 'put_trained_model_alias'
92-
args.merge!('reassign' => true) unless args['reassign'] === false
92+
args.merge!('reassign' => true) unless args['reassign'] == false
9393
@response = client.send(_method, prepare_arguments(args, test))
9494
client
9595
else
@@ -119,8 +119,14 @@ def prepare_arguments(args, test)
119119
# Find the cached values where the variable name is contained in the arguments.
120120
if(cached_values = test.cached_values.keys.select { |k| value =~ /\$\{?#{k}\}?/ })
121121
cached_values.each do |cached|
122-
# The arguments may contain the variable in the form ${variable} or $variable
123-
value.gsub!(/\$\{?#{cached}\}?/, test.cached_values[cached].to_s)
122+
# Arguments can be $variable, ${variable} or a Hash:
123+
retrieved = test.cached_values[cached]
124+
if retrieved.is_a?(Hash)
125+
value = retrieved
126+
else
127+
# Regex substitution to replace ${variable} or $variable for the value
128+
value.gsub!(/\$\{?#{cached}\}?/, retrieved.to_s)
129+
end
124130
end
125131
args[key] = value
126132
end

0 commit comments

Comments
 (0)