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)
137 138 139 |
# File 'lib/telegram/bot/rspec/client_matchers.rb', line 137 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.
143 144 145 146 147 148 149 |
# File 'lib/telegram/bot/rspec/client_matchers.rb', line 143 def (bot, text = nil, = {}) description = "send telegram message #{text.inspect}" text = a_string_matching(text) if text.is_a?(Regexp) = .merge(text: text) if text MakeTelegramRequest.new(bot, :sendMessage, description: description). with(hash_including()) end |