class Object
Public Instance Methods
get_url(path)
click to toggle source
# File lib/alinta-testing/overrides/get_url.rb, line 2 def get_url(path) raise %(Please set an 'endpoint' environment variable provided with the url of the api) unless ENV.key?('endpoint') get_url_internal(path, ENV['endpoint'], @urlbasepath, ENV['api_version']) end
get_url_internal(path, endpoint, urlbasepath, apiversion)
click to toggle source
# File lib/alinta-testing/overrides/get_url.rb, line 8 def get_url_internal(path, endpoint, urlbasepath, apiversion) # remove leading and trailing slashes endpoint = endpoint.gsub(/^(.*?)\/?$/, '\1') path = path.gsub(/^\/?(.*?)\/?$/, '\1') unless path.to_s.empty? urlbasepath = urlbasepath.gsub(/^\/?(.*?)\/?$/, '\1') unless urlbasepath.to_s.empty? apiversion = apiversion.gsub(/^\/?(.*?)\/?$/, '\1') unless apiversion.to_s.empty? path = "#{urlbasepath}/#{path}" unless urlbasepath.to_s.empty? splitpath = path.split('/') basepath = splitpath.first() path = splitpath.drop(1).join('/') # base end point for all calls url = endpoint # common sub-path for this feature url = "#{url}/#{basepath}" unless basepath.to_s.empty? # versioned route for UAT environments url = "#{url}/#{apiversion}" unless apiversion.to_s.empty? # final path for this request url = "#{url}/#{path}" unless path.to_s.empty? url end
parse_attributes(hashes)
click to toggle source
# File lib/alinta-testing/overrides.rb, line 14 def parse_attributes(hashes) hashes.each_with_object({}) do |row, hash| name = row['attribute'] value = row['value'] type = row['type'] # this condition is new and allows the value to be resolved from ruby code if type == 'expression' value = eval(value) else value = resolve_functions(value) value = resolve(value) value.gsub!(/\\n/, "\n") value = string_to_type(value, type) end names = split_fields(name) new_hash = names.reverse.inject(value) { |a, n| add_to_hash(a, n) } hash.deep_merge!(new_hash) { |_, old, new| new.is_a?(Array) ? merge_arrays(old, new) : new } end end