зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-03 09:46:17 +03:00
Support for testing bots in poller mode and non-Rails apps
Этот коммит содержится в:
24
spec/support/examples/integration.rb
Обычный файл
24
spec/support/examples/integration.rb
Обычный файл
@@ -0,0 +1,24 @@
|
||||
RSpec.shared_examples 'shared integration examples' do
|
||||
let(:bot) { Telegram::Bot::ClientStub.new('token') }
|
||||
let(:controller_class) do
|
||||
Class.new(Telegram::Bot::UpdatesController) do
|
||||
def start(data = nil, *)
|
||||
respond_with :message, text: "Hi #{data}"
|
||||
end
|
||||
|
||||
def callback_query(data, *)
|
||||
answer_callback_query "pong: #{data}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#start' do
|
||||
subject { -> { dispatch_command(:start, :test_data) } }
|
||||
it { should respond_with_message('Hi test_data') }
|
||||
end
|
||||
|
||||
describe '#callback_query', :callback_query do
|
||||
let(:data) { :test_data }
|
||||
it { should answer_callback_query "pong: #{data}" }
|
||||
end
|
||||
end
|
||||
Ссылка в новой задаче
Block a user