Sha256: 942c2bce171537d17677c2b5e259ce15fe40033255400b3e27c912150dca270c

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module Turn

  #
  class TestSuite

    include Enumerable

    attr_accessor :name
    attr_accessor :size
    attr_accessor :cases

    # This one can be set manually since it
    # is not calculatable (beyond the case level).
    attr_accessor :count_assertions

    #
    def initialize(name=nil)
      @name  = name
      @size  = nil
      @cases = []

      #@count_tests      = nil
      #@count_assertions = nil
      #@count_failures   = nil
      #@count_errors     = nil
      #@count_passes     = nil
    end

    #
    def new_case(name, *files)
      c = TestCase.new(name, *files)
      @cases << c
      c
    end

    def count_failures
      #@count_failures ||= (
        sum = 0; each{ |c| sum += c.count_failures }; sum
      #)
    end

    def count_errors
      #@count_errors ||= (
        sum = 0; each{ |c| sum += c.count_errors }; sum
      #)
    end

    def count_passes
      #@count_passes ||= (
        sum = 0; each{ |c| sum += c.count_passes }; sum
      #)
    end

    def count_tests
      #@count_tests ||= (
        sum = 0; each{ |c| sum += c.count_tests }; sum
      #)
    end

    def count_assertions
      #@count_assertions ||= (
        sum = 0; each{ |c| sum += c.count_assertions }; sum
      #)
    end

    # Convenience methods --this is what is typcially wanted.
    def counts
      return count_tests, count_assertions, count_failures, count_errors
    end

    def each(&block)
      @cases.each(&block)
    end

    def size
      @size ||= @cases.size
    end

  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
TwP-turn-0.5.1 lib/turn/components/suite.rb
TwP-turn-0.6.0 lib/turn/components/suite.rb
turn-0.7.0 lib/turn/components/suite.rb
turn-0.6.3 lib/turn/components/suite.rb
turn-0.6.2 lib/turn/components/suite.rb
turn-0.6.1 lib/turn/components/suite.rb
turn-0.5.1 lib/turn/components/suite.rb
turn-0.6.0 lib/turn/components/suite.rb
turn-0.4.0 lib/turn/components/suite.rb