spec/integration/rambling/trie_spec.rb in rambling-trie-2.3.0 vs spec/integration/rambling/trie_spec.rb in rambling-trie-2.3.1

- old
+ new

@@ -6,34 +6,30 @@ describe Rambling::Trie do let(:assets_path) { File.join ::SPEC_ROOT, 'assets' } context 'when providing words directly' do it_behaves_like 'a compressible trie' do - let(:trie) { Rambling::Trie.create } + let(:trie) { described_class.create } let(:words) { %w(a couple of words for our full trie integration test) } - before do - trie.concat words - end + before { trie.concat words } end end context 'when provided with words with unicode characters' do it_behaves_like 'a compressible trie' do - let(:trie) { Rambling::Trie.create } + let(:trie) { described_class.create } let(:words) do %w(poquísimas palabras para nuestra prueba de integración completa 🙃) end - before do - trie.concat words - end + before { trie.concat words } end end context 'when provided with a filepath' do - let(:trie) { Rambling::Trie.create filepath } + let(:trie) { described_class.create filepath } let(:words) { File.readlines(filepath).map(&:chomp) } context 'with english words' do it_behaves_like 'a compressible trie' do let(:filepath) { File.join assets_path, 'test_words.en_US.txt' } @@ -51,36 +47,37 @@ let(:words_filepath) { File.join assets_path, 'test_words.en_US.txt' } let(:words) { File.readlines(words_filepath).map(&:chomp) } context 'when serialized with Ruby marshal format (default)' do it_behaves_like 'a serializable trie' do - let(:trie_to_serialize) { Rambling::Trie.create words_filepath } + let(:trie_to_serialize) { described_class.create words_filepath } let(:format) { :marshal } end end context 'when serialized with YAML' do it_behaves_like 'a serializable trie' do - let(:trie_to_serialize) { Rambling::Trie.create words_filepath } + let(:trie_to_serialize) { described_class.create words_filepath } let(:format) { :yml } end end context 'when serialized with zipped Ruby marshal format' do + let!(:original_on_exists_proc) { ::Zip.on_exists_proc } + let!(:original_continue_on_exists_proc) { ::Zip.continue_on_exists_proc } + before do - @original_on_exists_proc = ::Zip.on_exists_proc - @original_continue_on_exists_proc = ::Zip.continue_on_exists_proc ::Zip.on_exists_proc = true ::Zip.continue_on_exists_proc = true end after do - ::Zip.on_exists_proc = @original_on_exists_proc - ::Zip.continue_on_exists_proc = @original_continue_on_exists_proc + ::Zip.on_exists_proc = original_on_exists_proc + ::Zip.continue_on_exists_proc = original_continue_on_exists_proc end it_behaves_like 'a serializable trie' do - let(:trie_to_serialize) { Rambling::Trie.create words_filepath } + let(:trie_to_serialize) { described_class.create words_filepath } let(:format) { 'marshal.zip' } end end end end