Sha256: fdb639e71d1e6920b5d2897ea5defade0e99d0cf94f0b0ca48646f913d70aebc

Contents?: true

Size: 950 Bytes

Versions: 5

Compression:

Stored size: 950 Bytes

Contents

require 'spec_helper'

module Rambling
  module Trie
    describe Enumerable do
      let(:root) { Root.new }
      let(:words) { %w(add some words and another word) }

      before do
        words.each { |word| root << word.clone }
      end

      describe '#each' do
        it 'returns an enumerator' do
          expect(root.each).to be_a Enumerator
        end

        it 'includes every word contained in the trie' do
          root.each { |word| expect(words).to include word }
          expect(root.count).to eq words.count
        end
      end

      describe '#size' do
        it 'delegates to #count' do
          expect(root.size).to eq words.size
        end
      end

      it 'includes the core Enumerable module' do
        expect(root.all? { |word| words.include? word }).to be_true
        expect(root.any? { |word| word.start_with? 's' }).to be_true
        expect(root.to_a).to match_array words
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rambling-trie-0.6.1 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.6.0 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.5.2 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.5.1 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.5.0 spec/lib/rambling/trie/enumerable_spec.rb