Sha256: c7347ae72d5e6f2d3558bee82524eb4888b6025f04cdd0357b30d273825b0667

Contents?: true

Size: 970 Bytes

Versions: 7

Compression:

Stored size: 970 Bytes

Contents

require 'spec_helper'

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

      before do
        words.each { |word| root.add 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

7 entries across 7 versions & 1 rubygems

Version Path
rambling-trie-1.0.2 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-1.0.1 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-1.0.0 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.9.3 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.9.2 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.9.1 spec/lib/rambling/trie/enumerable_spec.rb
rambling-trie-0.9.0 spec/lib/rambling/trie/enumerable_spec.rb