Class: Fitting::Report::Responses
- Inherits:
-
Object
- Object
- Fitting::Report::Responses
- Defined in:
- lib/fitting/report/responses.rb
Defined Under Namespace
Classes: NotFound
Instance Method Summary collapse
- #find!(log) ⇒ Object
-
#initialize(responses) ⇒ Responses
constructor
A new instance of Responses.
- #to_a ⇒ Object
Constructor Details
#initialize(responses) ⇒ Responses
Returns a new instance of Responses.
15 16 17 18 19 20 21 |
# File 'lib/fitting/report/responses.rb', line 15 def initialize(responses) @responses = responses @responses = [] responses.to_a.map do |response| @responses.push(Fitting::Report::Response.new(response)) end end |
Instance Method Details
#find!(log) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fitting/report/responses.rb', line 23 def find!(log) = "" @responses.map do |response| if response.status.to_s == log.status if JSON::Validator.fully_validate(response.body, log.body) == [] return response else += "\nbody: #{response.body}\nvalidate: #{JSON::Validator.fully_validate(response.body, log.body)}\n" end else += "\nstatus: #{response.status}\n" end end raise NotFound.new("method: #{log.method}, host: #{log.host}, path: #{log.path}, status: #{log.status}, body: #{log.body}\n\n#{}", log) end |
#to_a ⇒ Object
40 41 42 |
# File 'lib/fitting/report/responses.rb', line 40 def to_a @responses end |