class ResponseField
Handle parsing a field from a response
Public Class Methods
new(names)
click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 36 def initialize(names) @fields = split_fields(names) end
Public Instance Methods
get_value(response, type)
click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 44 def get_value(response, type) response.get_as_type to_json_path, parse_type(type) end
to_json_path()
click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 40 def to_json_path "#{root_data_key}#{@fields.join('.')}" end
validate_value(response, value, regex)
click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 48 def validate_value(response, value, regex) raise "Expected #{json_path} value '#{value}' to match regex: #{regex}\n#{response.to_json_s}" \ if (regex =~ value).nil? end