Sha256: c807e96f83e676942693d10d088d2eb51e1c85129286b157c6b5abdef6d90f02

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe LittleWeasel::Preprocessors::PreprocessedWords, type: :module do
  subject { create(:preprocessed_words, original_word: original_word, preprocessed_words: preprocessed_words) }

  let(:original_word) { 'word' }
  let(:preprocessed_words) {}

  #.new
  describe '.new' do
    it 'instantiates an object' do
      expect { subject }.to_not raise_error
    end

    context 'arguments' do
      context '#original_word' do
        it 'sets the original_word attribute' do
          expect(subject.original_word).to eq original_word
        end
      end

      context '#preprocessed_words' do
        let(:preprocessed_words) { [:preprocessed_words] }

        it 'sets the original_word attribute' do
          expect(subject.preprocessed_words).to eq preprocessed_words
        end
      end
    end
  end

  #preprocessed_word
  describe '#preprocessed_word' do
    subject do
      create(:preprocessed_words,
        with_word_processors: 3,
        original_word: original_word,
        preprocessed_words: preprocessed_words)
    end

    it 'returns the preprocessed word' do
      expect(subject.preprocessed_word).to eq 'word-0-1-2'
    end
  end

   #preprocessed?
  describe '#preprocessed?' do
    context 'when the word has been preprocessed' do
      subject do
        create(:preprocessed_words,
          with_word_processors: 1,
          original_word: original_word,
          preprocessed_words: preprocessed_words)
      end

      it 'returns the preprocessed word' do
        expect(subject.preprocessed?).to eq true
      end
    end

    context 'when the word has NOT been preprocessed' do
      subject do
        create(:preprocessed_words,
          original_word: original_word,
          preprocessed_words: preprocessed_words)
      end

      it 'returns the preprocessed word' do
        expect(subject.preprocessed?).to eq false
      end
    end
  end
end


Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
LittleWeasel-5.0.5 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb
LittleWeasel-5.0.4 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb
LittleWeasel-5.0.3 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb
LittleWeasel-5.0.2 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb
LittleWeasel-5.0.1 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb
LittleWeasel-5.0.0 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb
LittleWeasel-4.0.0 spec/lib/LittleWeasel/preprocessors/preprocessed_words_spec.rb