Sha256: 6b403cb4decadcd36552013e837be5c097da10616bee20b5191d6af891c95582

Contents?: true

Size: 1.72 KB

Versions: 17

Compression:

Stored size: 1.72 KB

Contents

require 'fitting/records/test_unit/request'

module Fitting
  class Records
    class RealizedUnit
      def initialize(realized_requests, documented_requests)
        @realized_requests = realized_requests
        @documented_requests = documented_requests
      end

      def fully_covered?
        test_file_paths.each do |_key, requests|
          all_good = requests.all?(&:documented?)
          return false unless all_good
        end
        test_file_paths.each do |_key, requests|
          all_good = requests.all?(&:response_documented?)
          return false unless all_good
        end
        test_file_paths.each do |_key, requests|
          all_good = requests.all?(&:response_json_schemas?)
          return false unless all_good
        end
        test_file_paths.each do |_key, requests|
          all_good = requests.all?(&:valid_json_schemas?)
          return false unless all_good
        end
        true
      end

      def test_file_paths
        return @test_file_paths if @test_file_paths
        @test_file_paths = {}
        white_unit.map do |request|
          @test_file_paths[request.test_file_path] ||= []
          @test_file_paths[request.test_file_path].push(request)
        end
        @test_file_paths
      end

      def all_documented_requests
        @all_documented_requests ||= @documented_requests.to_a.inject([]) do |res, tomogram_request|
          res.push(Fitting::Records::Documented::Request.new(tomogram_request, nil))
        end
      end

      def white_unit
        @white_unit_requests ||= @realized_requests.to_a.inject([]) do |res, tested_request|
          res.push(Fitting::Records::TestUnit::Request.new(tested_request, all_documented_requests))
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fitting-2.17.0 lib/fitting/records/realized_unit.rb
fitting-2.16.1 lib/fitting/records/realized_unit.rb
fitting-2.16.0 lib/fitting/records/realized_unit.rb
fitting-2.15.0 lib/fitting/records/realized_unit.rb
fitting-2.14.1 lib/fitting/records/realized_unit.rb
fitting-2.14.0 lib/fitting/records/realized_unit.rb
fitting-2.13.1 lib/fitting/records/realized_unit.rb
fitting-2.13.0 lib/fitting/records/realized_unit.rb
fitting-2.12.1 lib/fitting/records/realized_unit.rb
fitting-2.12.0 lib/fitting/records/realized_unit.rb
fitting-2.11.0 lib/fitting/records/realized_unit.rb
fitting-2.10.0 lib/fitting/records/realized_unit.rb
fitting-2.9.1 lib/fitting/records/realized_unit.rb
fitting-2.9.0 lib/fitting/records/realized_unit.rb
fitting-2.8.1 lib/fitting/records/realized_unit.rb
fitting-2.8.0 lib/fitting/records/realized_unit.rb
fitting-2.7.2 lib/fitting/records/realized_unit.rb