Add tests for log_service initializer script

pull/554/head
Rick Carlino 2017-12-06 14:51:25 -06:00
parent c22846577a
commit 214703b0ea
1 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,26 @@ describe LogService do
device_id = FactoryBot.create(:device).id
fake_delivery_info = FakeDeliveryInfo.new("bot.device_#{device_id}.logs")
class FakeLogChan
attr_reader :subcribe_calls
def initialize
@subcribe_calls = 0
end
def subscribe(*)
@subcribe_calls += 1
end
end
it "calls .subscribe() on Transport." do
fakee = FakeLogChan.new
allow(Transport).to receive(:log_channel) { fakee }
expect(fakee.subcribe_calls).to eq(0)
load "lib/log_service.rb"
expect(fakee.subcribe_calls).to eq(1)
end
it "creates new messages in the DB when called" do
Log.destroy_all
b4 = Log.count