class ResponseField

Public Class Methods

new(names) click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 30
def initialize(names)
    @fields = get_fields(names)
end

Public Instance Methods

get_value(response, type) click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 38
def get_value(response, type)
    return 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 34
def to_json_path()
    return "#{get_root_data_key()}#{@fields.join('.')}"
end
validate_value(response, value, regex) click to toggle source
# File lib/cucumber-rest-bdd/types.rb, line 42
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