module Telegram::Bot::RSpec::ClientMatchers
Matchers to test requests to Telegram
API.
Complex matchers requires `rspec-mocks` to be installed.
Public Instance Methods
make_telegram_request(bot, action)
click to toggle source
Check that bot performed request to telegram API:
expect { dispatch_message('Hi!') }. to make_telegram_request(bot, :sendMessage). with(text: 'Hello!', chat_id: chat_id)
# File lib/telegram/bot/rspec/client_matchers.rb, line 135 def make_telegram_request(bot, action) MakeTelegramRequest.new(bot, action) end
send_telegram_message(bot, text = nil, options = {})
click to toggle source
Helper for asserting message is sent. Note that options are checked with `hash_including`. For strict checks use make_telegram_request
.
# File lib/telegram/bot/rspec/client_matchers.rb, line 141 def send_telegram_message(bot, text = nil, options = {}) description = "send telegram message #{text.inspect}" text = a_string_matching(text) if text.is_a?(Regexp) options = options.merge(text: text) if text MakeTelegramRequest.new(bot, :sendMessage, description: description). with(hash_including(options)) end