README.md in telegram-bot-0.11.3 vs README.md in telegram-bot-0.12.0
- old
+ new
@@ -25,10 +25,12 @@
Run it on your local machine in 1 minute!
And here is [app teamplate](https://github.com/telegram-bot-rb/rails_template)
to generate clean app in seconds.
+Examples and cookbook in [wiki](https://github.com/telegram-bot-rb/telegram-bot/wiki).
+
## Installation
Add this line to your application's Gemfile:
```ruby
@@ -164,10 +166,24 @@
end
end
end
```
+#### Reply helpers
+
+There are helpers to respond for basic actions. They just set chat/message/query
+identifiers from update. See `ReplyHelpers` method for more information.
+Here are this methods signatures:
+
+```ruby
+def respond_with(type, params); end
+def reply_with(type, params); end
+def answer_inline_query(results, params = {}); end
+def answer_callback_query(text, params = {}); end
+def edit_message(type, params = {}); end
+```
+
#### Optional typecasting
You can enable typecasting of `update` with `telegram-bot-types` by including
`Telegram::Bot::UpdatesPoller::TypedUpdate`:
@@ -339,10 +355,12 @@
# rails_helper.rb
RSpec.configure do |config|
# ...
config.after { Telegram.bot.reset }
+ # or for multiple bots:
+ config.after { Telegram.bots.each_value(&:reset) }
# ...
end
```
There are integration and controller contexts for RSpec and some built-in matchers:
@@ -357,10 +375,17 @@
describe '#start' do
subject { -> { dispatch_command :start } }
it { should respond_with_message 'Hi there!' }
end
+
+ # There is context for callback queries with related matchers.
+ describe '#hey_callback_query', :callback_query do
+ let(:data) { "hey:#{name}" }
+ let(:name) { 'Joe' }
+ it { should answer_callback_query('Hey Joe') }
+ it { should edit_current_message :text, text: 'Done' }
end
# For controller specs use
require 'telegram/bot/updates_controller/rspec_helpers'
RSpec.describe TelegramWebhooksController, type: :telegram_bot_controller do
@@ -373,9 +398,13 @@
expect(&process_update).to send_telegram_message(bot, /msg regexp/, some: :option)
expect(&process_update).
to make_telegram_request(bot, :sendMessage, hash_including(text: 'msg text'))
```
+
+Place integration tests inside `spec/requests`
+when using RSpec's `infer_spec_type_from_file_location!`,
+or just add `type: :request` to `describe`.
See sample app for more examples.
### Deploying