Class: Request
- Inherits:
-
Object
- Object
- Request
- Defined in:
- lib/tester/definition/request.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
- #add_field(new_field) ⇒ Object
- #altered_payload(field_name, value) ⇒ Object
- #cases ⇒ Object
- #default_headers ⇒ Object
- #default_payload ⇒ Object
-
#initialize ⇒ Request
constructor
A new instance of Request.
- #payload ⇒ Object
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
8 9 10 |
# File 'lib/tester/definition/request.rb', line 8 def initialize self.fields = [] end |
Instance Attribute Details
#definition ⇒ Object
Returns the value of attribute definition.
4 5 6 |
# File 'lib/tester/definition/request.rb', line 4 def definition @definition end |
#fields ⇒ Object
Returns the value of attribute fields.
6 7 8 |
# File 'lib/tester/definition/request.rb', line 6 def fields @fields end |
#headers ⇒ Object
Returns the value of attribute headers.
5 6 7 |
# File 'lib/tester/definition/request.rb', line 5 def headers @headers end |
Instance Method Details
#add_field(new_field) ⇒ Object
12 13 14 15 |
# File 'lib/tester/definition/request.rb', line 12 def add_field(new_field) self.fields << new_field self end |
#altered_payload(field_name, value) ⇒ Object
44 45 46 47 48 |
# File 'lib/tester/definition/request.rb', line 44 def altered_payload field_name, value body = payload body[field_name] = value body end |
#cases ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/tester/definition/request.rb', line 33 def cases boundary_cases = Array.new self.fields.each do |field| field.negative_boundary_values.each do |value| bcase = BoundaryCase.new("Setting #{field.name} to #{value}", altered_payload(field.name, value), default_headers) boundary_cases.push(bcase) end end boundary_cases end |
#default_headers ⇒ Object
29 30 31 |
# File 'lib/tester/definition/request.rb', line 29 def default_headers {content_type: :json, accept: :json} end |
#default_payload ⇒ Object
25 26 27 |
# File 'lib/tester/definition/request.rb', line 25 def default_payload payload end |
#payload ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/tester/definition/request.rb', line 17 def payload response = Hash.new self.fields.each do |field| response[field.name] = field.default_value end response end |