我的处理程序有 4 个配置输入
config :base_url
config :details_path
config :create_path
config :token
我在lita_config文件中设置为它们,但要测试我的处理程序,我也需要在规范中为他设置值。我该怎么做?
显然,您可以通过registry
对象执行此操作:
describe Lita::Handlers::MyHandler, lita_handler: true do
before do
registry.config.handlers.my_handler.base_url = 'base url here'
registry.config.handlers.my_handler.details_path = 'some path'
...
end
... actual testing ...
end
我在文档中的任何地方都找不到这些信息。我终于通过查看其他插件的测试弄清楚了,所以我想我会在这里记录它。
希望这有帮助!