Class: ResponseField
- Inherits:
-
Object
- Object
- ResponseField
- Defined in:
- lib/cucumber-rest-bdd/types.rb
Instance Method Summary collapse
- #get_value(type) ⇒ Object
-
#initialize(names) ⇒ ResponseField
constructor
A new instance of ResponseField.
- #to_json_path ⇒ Object
- #validate_value(value, regex) ⇒ Object
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_path ⇒ Object
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 |