aboutsummaryrefslogtreecommitdiff
path: root/spec/lib/message_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/message_spec.rb')
-rw-r--r--spec/lib/message_spec.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/spec/lib/message_spec.rb b/spec/lib/message_spec.rb
index 2605117..8994216 100644
--- a/spec/lib/message_spec.rb
+++ b/spec/lib/message_spec.rb
@@ -7,8 +7,9 @@ require_relative '../../lib/chotto/helpers'
RSpec.describe Chotto::Message do
let(:tags) { [] }
let(:msg) { double('Notmuch::Message', tags: tags) }
+ let(:db_double) { double('Chotto::Database') }
- let(:subject) { Chotto::Message.new(msg: msg) }
+ let(:subject) { Chotto::Message.new(msg: msg, db: db_double) }
it 'reads headers' do
expect(msg).to receive(:header).with('A-Header')
@@ -43,4 +44,22 @@ RSpec.describe Chotto::Message do
subject.save!
end
end
+
+ describe 'thread' do
+ let(:thread_id) { '1' }
+ let(:tester) { double }
+ let(:msg_in_thread) { double('Chotto:Message') }
+
+ it 'fetches messages for thread' do
+ expect(msg).to receive(:thread_id).and_return(thread_id)
+ expect(db_double).to receive(:search_messages).with("thread:#{thread_id}").and_return([msg_in_thread])
+ expect(msg_in_thread).to receive(:tags)
+
+ expect(tester).to receive(:test).with(an_instance_of(Chotto::Message))
+
+ subject.thread.each do |msg|
+ tester.test(msg)
+ end
+ end
+ end
end