How can I set config on Lita Handler for tests?

73 Views Asked by At

My handler have 4 configs input

  config :base_url
  config :details_path
  config :create_path
  config :token

I set to them in my lita_config file, but to test my handler, I need set values to him on my specs as well. How can I do this?

1

There are 1 best solutions below

1
On BEST ANSWER

Apparently you can do this through the registry object:

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

I couldn't find this information anywhere in docs either. I finally figured it out by looking at tests of other plugins, so I figured I'd document it here.

Hope this helps!