我有一个包含http块的Inspec控件。该网址保存在名为DNScloudui['value']
的变量中-我想在该网址的开头添加https://
。
DNScloudui = attribute('DNS_name_cloudui')
control 'Website reachability' do
title 'Check reachability by GET requests'
describe http(DNScloudui['value'], method: 'GET') do
its('status') { should cmp 200 }
end
end
我该如何实现?
答案 0 :(得分:1)
假设DNScloudui
返回一个非nil值,那么您可以使用字符串插值来获取DNScloudui
变量的值。例如:
DNScloudui = attribute('DNS_name_cloudui')
control 'Website reachability' do
title 'Check reachability by GET requests'
describe http("https://#{DNScloudui['value']}", method: 'GET') do
its('status') { should cmp 200 }
end
end
还要查看您的DNScloudui
变量的名称,我建议您坚持使用ruby naming conventions and style guides