diff options
author | mms <git@sapka.me> | 2024-11-14 22:34:47 +0100 |
---|---|---|
committer | mms <git@sapka.me> | 2024-11-14 22:34:57 +0100 |
commit | 8c084e0faa971e6db265ea39aefb8cf07e39de43 (patch) | |
tree | 899e4f6f8e7e33ab01d09ad917c86fd32944a4bb /spec/lib/database_spec.rb | |
parent | 4d87cb470b2c306c126d2d739d50577702374926 (diff) |
chore: add specs for all classes
Diffstat (limited to 'spec/lib/database_spec.rb')
-rw-r--r-- | spec/lib/database_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/database_spec.rb b/spec/lib/database_spec.rb new file mode 100644 index 0000000..8da04e4 --- /dev/null +++ b/spec/lib/database_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'rspec' +require_relative '../../lib/chotto/database' + +RSpec.describe Chotto::Database do + let(:db_double) { double('Notmuch::Database') } + let(:db_instance_double) { double('Notmuch::Database') } + let(:query_double) { double('Notmuch::Query') } + let(:query) { 'from:baltar@battlestar.com' } + let(:path) { '/var/db/mail' } + let(:subject) { Chotto::Database } + + before do + expect(db_double).to receive(:new).with(path, mode: Notmuch::MODE_READ_WRITE).and_return(db_instance_double) + end + + it 'initializes the database instance' do + subject.new(path: path, db_class: db_double) + end + + describe '#search_messages' do + it 'uses the correct method chain' do + expect(db_instance_double).to receive(:query).with(query).and_return(query_double) + expect(query_double).to receive(:search_messages) + + db = subject.new(path: path, db_class: db_double) + db.search_messages(query) + end + end +end |