зеркало из
https://github.com/glebtv/telegram-bot.git
synced 2026-09-06 02:55:50 +03:00
Ability to use type-castion with telegram-bot-types
Этот коммит содержится в:
27
spec/telegram/bot/updates_controller/typed_update_spec.rb
Обычный файл
27
spec/telegram/bot/updates_controller/typed_update_spec.rb
Обычный файл
@@ -0,0 +1,27 @@
|
||||
RSpec.describe Telegram::Bot::UpdatesController::TypedUpdate do
|
||||
include_context 'telegram/bot/updates_controller'
|
||||
let(:instance) { controller_class.new(bot, update) }
|
||||
let(:controller_class) do
|
||||
described_class = self.described_class
|
||||
Class.new(Telegram::Bot::UpdatesController) do
|
||||
include described_class
|
||||
end
|
||||
end
|
||||
|
||||
context 'when `update` is a virtus model' do
|
||||
subject { instance }
|
||||
%w(
|
||||
message
|
||||
inline_query
|
||||
chosen_inline_result
|
||||
).each do |type|
|
||||
context "with #{type}" do
|
||||
type_class = Telegram::Bot::Types.const_get(type.camelize)
|
||||
let(:payload_type) { type }
|
||||
let(:payload) { {} }
|
||||
its(:payload_type) { should eq payload_type }
|
||||
its(:payload) { should be_instance_of type_class }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Ссылка в новой задаче
Block a user