Sha256: a4c161ada55a944000ac5a0c753aa59c0fdae5b40b648a6d5fc6662d9beb24a8

Contents?: true

Size: 1.8 KB

Versions: 18

Compression:

Stored size: 1.8 KB

Contents

module Turn

  #
  class TestSuite

    include Enumerable

    attr_accessor :name
    attr_accessor :cases
    attr_accessor :seed

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

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

      #@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_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

    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_skips
      sum = 0; each{ |c| sum += c.count_skips }; sum
    end

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

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

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

    # Why the size would ever have to overridden... well who can say.
    def size=(number)
      @size = number.to_i
    end

    def passed?
      (count_failures == 0 && count_errors == 0)
    end
  end

end

Version data entries

18 entries across 18 versions & 5 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
turn-0.9.7 lib/turn/components/suite.rb
challah-1.0.0 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
swipe-rails-0.0.5 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-1.0.0.beta3 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-1.0.0.beta2 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-1.0.0.beta vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-0.9.1.beta.3 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-0.9.1.beta vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-0.9.0 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
challah-0.8.3 vendor/bundle/gems/turn-0.9.6/lib/turn/components/suite.rb
turn-0.9.6 lib/turn/components/suite.rb
challah-0.6.1 vendor/bundle/gems/turn-0.9.5/lib/turn/components/suite.rb
challah-0.6.0 vendor/bundle/gems/turn-0.9.5/lib/turn/components/suite.rb
turn-0.9.5 lib/turn/components/suite.rb
turn-0.9.4 lib/turn/components/suite.rb
turn-0.9.3 lib/turn/components/suite.rb