зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-07 19:35:52 +03:00
Telegram.bot raises error when there is no default config
Этот коммит содержится в:
@@ -34,7 +34,11 @@ module Telegram
|
|||||||
|
|
||||||
# Default bot.
|
# Default bot.
|
||||||
def bot
|
def bot
|
||||||
@bot ||= bots[:default]
|
@bot ||= bots.fetch(:default) do
|
||||||
|
raise 'Default bot is not configured.' \
|
||||||
|
' Add :default to bots_config' \
|
||||||
|
' or use telegram.bot/telegram.bots.default section in secrets.yml.'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Hash of botan clients made from #bots.
|
# Hash of botan clients made from #bots.
|
||||||
|
|||||||
@@ -22,8 +22,13 @@ RSpec.describe Telegram::Bot::ConfigMethods do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#bot' do
|
describe '#bot' do
|
||||||
subject { registry.bot }
|
subject { -> { registry.bot } }
|
||||||
it { should eq registry.bots[:default] }
|
its(:call) { should eq registry.bots[:default] }
|
||||||
|
|
||||||
|
context 'when bot is not configured' do
|
||||||
|
let(:config) { super().except(:default) }
|
||||||
|
it { should raise_error(/bot is not configured/) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#bots' do
|
describe '#bots' do
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user