Sha256: 4ac645731ff8f3c36bf936ee5482fb6940a044994d6c6b94b79122d02c3561e2

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

#
# File::       test_AllProcessors.rb
# Author::     wkm
# Copyright::  2009
# License::    GPL
#
# Programmatic tests run against all processors
#

$:.unshift File.join(File.dirname(__FILE__),'..','lib')

require 'test/unit'
require 'sitefuel/SiteFuelRuntime'
require 'sitefuel/processors/AbstractStringBasedProcessor'

include SiteFuel

class TestAllProcessors < Test::Unit::TestCase

  def setup
    SiteFuelRuntime.load_processors
    @processors = SiteFuelRuntime.
            find_processors.
            delete_if do |proc|
              proc.to_s =~ /.*Test.*Processor/
            end

    @string_processors = Processor::AbstractStringBasedProcessor.
            find_processors.
            delete_if do |proc|
              proc.to_s =~ /.*Test.*Processor/
            end
  end

  # ensure that every filter in every filter set is known
  def test_filter_sets
    @processors.each do |proc|
      proc.filtersets.each do |filterset|
        proc.filters_in_filterset(filterset).each do |filter|
          assert(
            proc.filter?(filter),
            'Filter %s in filterset %s isn\'t known for %s' %
            [filter, filterset, proc]
          )
        end
      end
    end
  end

  # test that every processor has a default filterset
  def test_default_filter_sets
    @processors.each do |proc|
      assert proc.filterset?(proc.default_filterset), 'Default filterset %s for %s isn\'t known'%[proc.default_filterset, proc]
    end
  end

  # test that every string based processor's filters can handle the empty string
  def test_string_based_empty_string
    @string_processors.each do |proc|
      proc.filters.each do |filter|
        assert_nothing_raised { proc.filter_string(filter, '') }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b test/test_AllProcessors.rb
sitefuel-0.0.0a test/test_AllProcessors.rb