Class: Fitting::Report::Responses
- Inherits:
-
Object
- Object
- Fitting::Report::Responses
- Defined in:
- lib/fitting/report/responses.rb
Instance Method Summary collapse
- #cram_into_the_appropriate_response(test) ⇒ Object
-
#initialize(responses) ⇒ Responses
constructor
A new instance of Responses.
- #is_there_a_suitable_response?(test) ⇒ Boolean
- #join(tests) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(responses) ⇒ Responses
Returns a new instance of Responses.
6 7 8 9 10 11 12 |
# File 'lib/fitting/report/responses.rb', line 6 def initialize(responses) @responses = responses @responses = [] responses.to_a.map do |response| @responses.push(Fitting::Report::Response.new(response)) end end |
Instance Method Details
#cram_into_the_appropriate_response(test) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/fitting/report/responses.rb', line 37 def cram_into_the_appropriate_response(test) @responses.map do |response| if response.status.to_s == test.status && JSON::Validator.fully_validate(response.body, test.body) == [] response.add_test(test) return end end end |
#is_there_a_suitable_response?(test) ⇒ Boolean
27 28 29 30 31 32 33 34 35 |
# File 'lib/fitting/report/responses.rb', line 27 def is_there_a_suitable_response?(test) return false if @responses.nil? @responses.map do |response| return true if response.status.to_s == test.status && JSON::Validator.fully_validate(response.body, test.body) == [] end false end |
#join(tests) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/fitting/report/responses.rb', line 18 def join(tests) tests.to_a.map do |test| if is_there_a_suitable_response?(test) cram_into_the_appropriate_response(test) test.mark_response end end end |
#to_a ⇒ Object
14 15 16 |
# File 'lib/fitting/report/responses.rb', line 14 def to_a @responses end |