Sha256: 7b58c62c4857a69f7fb7dfa72b558d1f1e5498ff72a1dc50c6e71d08ef2ef268

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

require 'spec_helper'
require 'haravan_theme/file_filters'

module HaravanTheme
  describe "FileFilters" do
    class IdentityFilter
      def select(list)
        list.select { true }
      end
    end

    class EvenFilter
      def select(list)
        list.select { |i| i % 2 == 0 }
      end
    end

    it "initializing without a filter raises an error" do
      assert_raises ArgumentError do
        FileFilters.new
      end
    end

    it "initializing with a single filter" do
      begin
        FileFilters.new(IdentityFilter.new)
      rescue Error => e
        flunk("Initializing with a single filter should not fail. #{e}")
      end
    end

    it "should only select entries that were valid for all of the given filters" do
      filters = FileFilters.new(IdentityFilter.new, EvenFilter.new)
      assert_equal [2, 4], filters.select([1, 2, 3, 4, 5])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
haravan_theme-0.0.26 spec/unit/file_filters_spec.rb
haravan_theme-0.0.25 spec/unit/file_filters_spec.rb