Sha256: 8390e7ce941b63795311779f2b931a93ded2f830854ced38f2ddf248474f051f

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 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.load(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.inject([]) do |result, test|
          result.push(test.path) unless test.is_there_a_prefix?
          result
        end
      end

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

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

      def without_combinations
        @tests.inject([]) do |result, test|
          result.push(test.path) unless test.is_there_an_combinations?
          result
        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.17.0 lib/fitting/report/tests.rb
fitting-2.16.1 lib/fitting/report/tests.rb
fitting-2.16.0 lib/fitting/report/tests.rb
fitting-2.15.0 lib/fitting/report/tests.rb