Sha256: 3761ffc331a3ec7775ca76fcc0d1c8e793cdc1051f5914ec28d8957b4f502db8
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' describe WordsToImage::Dictionary do SAMPLE_PATH = 'spec/fixtures/sample_dict' describe "#get_word" do let(:dictionary) { WordsToImage::Dictionary.new(SAMPLE_PATH) } it "should return one word from the set" do words = File.read(SAMPLE_PATH).split words.count.times do expect(words).to include(dictionary.get_word) end end it "should return words in random order" do dict2 = WordsToImage::Dictionary.new(SAMPLE_PATH) words = (1..5).map { dictionary.get_word } words2 = (1..5).map { dict2.get_word } expect(words).not_to eq words2 end context "no words left" do before do allow(dictionary).to receive(:read_content).and_return([]) end it "should return nil" do expect(dictionary.get_word).to be_nil end end context "file unreadable" do let(:inexisting_dict) { WordsToImage::Dictionary.new('/inexisting/path') } it "should raise an exception with verbose description" do expect{inexisting_dict.get_word}.to raise_error(IOError) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
words_to_image-0.0.3 | spec/words_to_image/dictionary_spec.rb |
words_to_image-0.0.2 | spec/words_to_image/dictionary_spec.rb |