зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 17:55:52 +03:00
rescue_from feature
Этот коммит содержится в:
31
spec/telegram/bot/updates_controller/rescue_spec.rb
Обычный файл
31
spec/telegram/bot/updates_controller/rescue_spec.rb
Обычный файл
@@ -0,0 +1,31 @@
|
||||
RSpec.describe Telegram::Bot::UpdatesController::Rescue do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
|
||||
describe '#process_action' do
|
||||
subject { -> { dispatch_message("/#{command} x y z") } }
|
||||
|
||||
let(:controller_class) do
|
||||
Class.new(Telegram::Bot::UpdatesController) do
|
||||
rescue_from ArgumentError, with: -> { respond_with :message, text: 'Rescued' }
|
||||
|
||||
def rescuable(*)
|
||||
raise ArgumentError, 'rescuable'
|
||||
end
|
||||
|
||||
def not_rescuable(*)
|
||||
raise 'not_rescuable'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when exception is rescued' do
|
||||
let(:command) { :rescuable }
|
||||
it { should respond_with_message 'Rescued' }
|
||||
end
|
||||
|
||||
context 'when exception is not rescued' do
|
||||
let(:command) { :not_rescuable }
|
||||
it { should raise_error('not_rescuable') }
|
||||
end
|
||||
end
|
||||
end
|
||||
Ссылка в новой задаче
Block a user