Class: ResponseField

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber-rest-bdd/types.rb

Instance Method Summary collapse

Constructor Details

#initialize(names) ⇒ ResponseField

Returns a new instance of ResponseField.



43
44
45
# File 'lib/cucumber-rest-bdd/types.rb', line 43

def initialize(names)
    @fields = get_fields(names)
end

Instance Method Details

#get_value(type) ⇒ Object



51
52
53
# File 'lib/cucumber-rest-bdd/types.rb', line 51

def get_value(type)
    return @response.get_as_type to_json_path(), parse_type(type)
end

#to_json_pathObject



47
48
49
# File 'lib/cucumber-rest-bdd/types.rb', line 47

def to_json_path()
    return "#{get_root_data_key()}#{@fields.join('.')}"
end

#validate_value(value, regex) ⇒ Object



55
56
57
# File 'lib/cucumber-rest-bdd/types.rb', line 55

def validate_value(value, regex)
    raise %/Expected #{json_path} value '#{value}' to match regex: #{regex}\n#{@response.to_json_s}/ if (regex =~ value).nil?
end