Module: Telegram::Bot::RSpec::ClientMatchers
- Defined in:
- lib/telegram/bot/rspec/client_matchers.rb
Overview
Matchers to test requests to Telegram API.
Complex matchers requires ‘rspec-mocks` to be installed.
Defined Under Namespace
Classes: MakeTelegramRequest
Instance Method Summary collapse
-
#make_telegram_request(bot, action) ⇒ Object
Check that bot performed request to telegram API:.
-
#send_telegram_message(bot, text = nil, options = {}) ⇒ Object
Helper for asserting message is sent.
Instance Method Details
#make_telegram_request(bot, action) ⇒ Object
Check that bot performed request to telegram API:
expect { ('Hi!') }.
to make_telegram_request(bot, :sendMessage).
with(text: 'Hello!', chat_id: chat_id)
135 136 137 |
# 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 = {}) ⇒ Object
Helper for asserting message is sent. Note that options are checked with ‘hash_including`. For strict checks use #make_telegram_request.
141 142 143 144 145 146 147 |
# File 'lib/telegram/bot/rspec/client_matchers.rb', line 141 def (bot, text = nil, = {}) text = a_string_matching(text) if text.is_a?(Regexp) = .merge(text: text) if text description = "send telegram message #{text.inspect}" MakeTelegramRequest.new(bot, :sendMessage, description: description). with(hash_including()) end |