Class: ResponseField
- Inherits:
-
Object
- Object
- ResponseField
- Defined in:
- lib/cucumber-rest-bdd/types.rb
Instance Method Summary collapse
- #get_value(response, type) ⇒ Object
-
#initialize(names) ⇒ ResponseField
constructor
A new instance of ResponseField.
- #to_json_path ⇒ Object
- #validate_value(response, value, regex) ⇒ Object
Constructor Details
#initialize(names) ⇒ ResponseField
Returns a new instance of ResponseField.
30 31 32 |
# File 'lib/cucumber-rest-bdd/types.rb', line 30 def initialize(names) @fields = get_fields(names) end |
Instance Method Details
#get_value(response, type) ⇒ Object
38 39 40 |
# 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 ⇒ Object
34 35 36 |
# 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) ⇒ Object
42 43 44 |
# 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 |