Sha256: 87c597fabc4d2bf801f80d289c6c6fb6d3524a8fba17863f84965f61a042f642

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

require 'fitting/report/test'

module Fitting
  module Report
    class Tests
      def initialize(tests)
        @tests = tests
      end

      def self.new_from_config(tests_path)
        tests = []
        Dir[tests_path].each do |file|
          JSON.parse(File.read(file)).map do |test|
            tests.push(Fitting::Report::Test.new(test))
          end
        end
        tests.sort { |a, b| b.path <=> a.path }
        new(tests)
      end

      def without_prefixes
        @tests.each_with_object([]) do |test, result|
          result.push(test.path) unless test.there_a_prefix?
        end
      end

      def without_actions
        @tests.each_with_object([]) do |test, result|
          result.push("#{test.method} #{test.path}") unless test.there_an_actions?
        end
      end

      def without_responses
        @tests.each_with_object([]) do |test, result|
          result.push(test.id) unless test.there_an_responses?
        end
      end

      def without_combinations
        @tests.each_with_object([]) do |test, result|
          result.push(test.path) unless test.there_an_combinations?
        end
      end

      def push(test)
        @tests.push(test)
      end

      def size
        @tests.size
      end

      def to_a
        @tests
      end

      def to_h
        return @hash if @hash

        @hash = @tests.inject({}) do |res, test|
          res.merge!(test.id => test.to_h)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fitting-2.18.3 lib/fitting/report/tests.rb
fitting-2.18.2 lib/fitting/report/tests.rb
fitting-2.18.1 lib/fitting/report/tests.rb
fitting-2.18.0 lib/fitting/report/tests.rb