From a2a9c6078dd6dd762d9e42cba1741d697a1f2291 Mon Sep 17 00:00:00 2001 From: Eric Budd Date: Wed, 8 Dec 2021 21:54:17 -0600 Subject: [PATCH] Flesh out some tests --- tests/iris_test.rb | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/iris_test.rb b/tests/iris_test.rb index b37b9ad..34118d8 100644 --- a/tests/iris_test.rb +++ b/tests/iris_test.rb @@ -4,6 +4,8 @@ require 'mocha/minitest' # This allows the test to pretend that user "jerryberry" is logged in. ENV['USER'] = 'jerryberry' +ENV['EDITOR'] = 'foo/bar' + # Set this before loading the code so that the Config constants load correctly. $test_corpus_file = "./tests/iris.messages.json" @@ -34,6 +36,10 @@ describe Config do _(Config::AUTHOR).must_equal "#{Config::USER}@#{Config::HOSTNAME}" end + it 'has the $EDITOR environment variable' do + _(Config::ENV_EDITOR).must_equal 'foo/bar' + end + describe '.find_files' do it 'looks up all the Iris message files on the system' do # I am so sorry about this `expects` clause @@ -97,10 +103,13 @@ describe Corpus do end it 'returns an empty array if the hash is not a parent of any other messages' do + _(Corpus.find_all_by_parent_hash(nil)).must_equal [] + end + + it 'returns an empty array if the hash is not found in the corpus' do _(Corpus.find_all_by_parent_hash('GoofMcDoof')).must_equal [] end - it 'returns an empty array if the hash is not found in the corpus' it 'returns the messages associated with the parent hash' end @@ -110,8 +119,13 @@ describe Corpus do end describe 'when an index string is passed in' do - it 'returns nil if the topic is not found' - it 'returns the associated topic' + it 'returns nil if the topic is not found' do + assert_nil Corpus.find_topic_by_id('InvalidTopicId') + end + + it 'returns the associated topic' do + _(Corpus.find_topic_by_id(1).message).must_equal 'Test' + end end end @@ -121,8 +135,13 @@ describe Corpus do end describe 'when a hash string is passed in' do - it 'returns nil if the topic is not found' - it 'returns the associated topic' + it 'returns nil if the topic is not found' do + assert_nil Corpus.find_topic_by_hash('BadHash') + end + + it 'returns the associated topic' do + _(Corpus.find_topic_by_hash("gpY2WW/jGcH+BODgySCwDANJlIM=\n").message).must_equal 'Test' + end end end end