зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-06 19:15:50 +03:00
Support for testing bots in poller mode and non-Rails apps
Этот коммит содержится в:
24
lib/telegram/bot/rspec/integration/rack.rb
Обычный файл
24
lib/telegram/bot/rspec/integration/rack.rb
Обычный файл
@@ -0,0 +1,24 @@
|
||||
require 'telegram/bot/rspec/integration/shared'
|
||||
require 'rack/test'
|
||||
|
||||
RSpec.shared_context 'telegram/bot/integration/rack' do
|
||||
include_context 'telegram/bot/integration/shared'
|
||||
include Rack::Test::Methods
|
||||
|
||||
let(:request_path) { raise '`let(:request_path) { path to bot }` is required' }
|
||||
let(:app) { raise '`let(:app) { your rack app here }` is required' }
|
||||
let(:request_headers) do
|
||||
{
|
||||
'ACCEPT' => 'application/json',
|
||||
'CONTENT_TYPE' => 'application/json',
|
||||
}
|
||||
end
|
||||
|
||||
def dispatch(update)
|
||||
post request_path, update.to_json, request_headers
|
||||
end
|
||||
end
|
||||
|
||||
Telegram::Bot::RSpec.with_include_context do |config|
|
||||
config.include_context 'telegram/bot/integration/rack', telegram_bot: :rack
|
||||
end
|
||||
Ссылка в новой задаче
Block a user