1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-09-06 19:15:50 +03:00
ActionDispatch::Testing::Integration requires smth else and
defines Rails, so had to change `defined?(Rails)` all over the code.
Этот коммит содержится в:
Max Melentiev
2016-11-16 14:16:45 +03:00
родитель 5c299887bb
Коммит 0c9a4a5fa0
7 изменённых файлов: 159 добавлений и 24 удалений

Просмотреть файл

@@ -13,6 +13,9 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
let(:bot) { Telegram::Bot::ClientStub.new(bot_name) }
let(:bot_name) { 'bot' }
let(:session) { controller.send(:session) }
let(:from_id) { 123 }
let(:chat_id) { 456 }
let(:default_message_options) { {from: {id: from_id}, chat: {id: chat_id}} }
include Telegram::Bot::RSpec::ClientMatchers
@@ -20,9 +23,8 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
controller.dispatch_again(bot, update)
end
def dispatch_message(text, options = nil)
options ||= respond_to?(:default_message_options) ? default_message_options : {}
update = build_update :message, options.merge(text: text)
def dispatch_message(text, options = {})
update = build_update :message, default_message_options.merge(options).merge(text: text)
dispatch bot, update
end
@@ -43,3 +45,9 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
send_telegram_message(bot, expected, chat_id: chat_id)
end
end
RSpec.configure do |config|
if config.respond_to?(:include_context)
config.include_context 'telegram/bot/updates_controller', type: :telegram_bot_controller
end
end