Sha256: a07f157b6dc04692fa1e435c9271e84b1f2c3b5191b19f1f7aa8731d4063da6e
Contents?: true
Size: 930 Bytes
Versions: 14
Compression:
Stored size: 930 Bytes
Contents
# Shared helpers for testing message updates. RSpec.shared_context 'telegram/bot/message_helpers' do let(:default_message_options) { {from: from, chat: chat} } let(:from) { {id: from_id} } let(:from_id) { 123 } let(:chat) { {id: chat_id} } let(:chat_id) { 456 } # Shortcut for dispatching messages with default params. def dispatch_message(text, options = {}) dispatch message: default_message_options.merge(options).merge(text: text) end # Dispatch command message. def dispatch_command(cmd, *args) options = args.last.is_a?(Hash) ? args.pop : {} args.unshift("/#{cmd}") dispatch_message(args.join(' '), options) end # Matcher to check response. Make sure to define `let(:chat_id)`. def respond_with_message(expected = Regexp.new('')) raise 'Define chat_id to use respond_with_message' unless defined?(chat_id) send_telegram_message(bot, expected, chat_id: chat_id) end end
Version data entries
14 entries across 14 versions & 1 rubygems