Sha256: a2173e2dc2d60b03110b641dfb0ddaffb56f114ba47b3646ec958fc2f2bd7b5b

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

require 'wordlist/unique_filter'

require 'spec_helper'

describe UniqueFilter do
  before(:each) do
    @filter = UniqueFilter.new
  end

  it "should have seen words" do
    @filter.saw!('cat')

    @filter.seen?('cat').should == true
    @filter.seen?('dog').should == false
  end

  it "should only see a unique word once" do
    @filter.saw!('cat').should == true
    @filter.saw!('cat').should == false
  end

  it "should pass only unique words through the filter" do
    input = ['dog', 'cat', 'dog']
    output = []

    input.each do |word|
      @filter.pass(word) do |result|
        output << result
      end
    end

    output.should == ['dog', 'cat']
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wordlist-0.1.1 spec/unique_filter_spec.rb
wordlist-0.1.0 spec/unique_filter_spec.rb