-
Notifications
You must be signed in to change notification settings - Fork 118
Upgrading to 0.14
Gem's API getting more stable with every minor update and I expect next version be a major release. However there was some issues that had to be addressed before first major release. So 0.14 version goes with some breaking changes. This update is going to make bots more secure and source-code more consistent, trying to keep code clean and simple - this is what we like Ruby for.
See upgrade commit in example app.
Please see #85 for rationale and discussion.
Change method names for command to their bang-version. Make sure to update save_context
if you used command name as context name.
# was
def start(*)
end
def rename(name = nil, *)
if name
else
save_context :rename
end
end
# becomes
def start!(*)
end
def rename!(name = nil, *)
if name
else
save_context :rename!
end
end
Because of using bang-methods for commands, there are no more name conflicts. Change all context_handler
s to usual ruby methods, remove context_to_action!
calls.
# was
context_to_action!
context_handler :rename do |name, *|
end
# becomes
def rename(name, *)
end
0.14 brings RSpec contexts for testing bots in poller mode and in rack applications without Rails. To make it consistent, it's required to specify exact context type.
# was
RSpec.describe BotController, :telegram_bot do
# becomes
RSpec.describe BotController, telegram_bot: :rails do
Controller specs getting consistent with integration specs, so dispatch
method changed it's signature. To simplify API build_update
is dropped in favour of deep_stringify
. In this update controller specs receives all matchers and helpers available in request specs.
# was
dispatch(bot, update)
build_update(type, data)
# becomes
dispatch(update, bot)
deep_stringify(type => data)