lib/api-tester/reporter/api_report.rb in api-tester-1.0.0 vs lib/api-tester/reporter/api_report.rb in api-tester-1.1.1

- old
+ new

@@ -1,39 +1,47 @@ +# frozen_string_literal: true + require 'api-tester/reporter/report' module ApiTester + # class for dealing with reports generated by the modules during test suite class ApiReport attr_accessor :reports def initialize self.reports = [] end - def add_new url, request, expected_response, actual_response, description="A case" - report = Report.new description, url, request, expected_response, actual_response - self.reports << report + def add_new(url:, request:, expected_response:, actual_response:, description: 'case') + report = Report.new description, + url, + request, + expected_response, + actual_response + reports << report end - def add_new_report report - self.reports << report + def add_new_report(report) + reports << report end - def add_reports reports - self.reports.concat reports + def add_reports(reports) + reports.each do |report| + add_new_report(report) + end end def print - if self.reports.size > 0 - puts "Issues discovered: #{self.reports.size}" - self.reports.each do |report| + if reports.size.zero? + puts 'No issues found' + else + puts "Issues discovered: #{reports.size}" + reports.each do |report| report.print - puts "\n" - puts "\n" + puts '\n' + puts '\n' end - puts "" - puts "Issues discovered: #{self.reports.size}" - else - puts "No issues found" + puts "Total issues: #{reports.size}" end end end end