How to set values for config's of my handler in tests?

0

My handler has 4 configuration variables:

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

I hedge them and my lita_config file, but to test my handler, I need to set values for them in my specs too, how can I do that?

    
asked by anonymous 10.05.2017 / 15:51

2 answers

0

In rspec for the set of settings defined for a Lita Handler can be done using registry . For example, in my case, my handler calls dpeauth , to set these 3 configuration variables we can do this:

registry.config.handlers.dpeauth.base_url = 'valor'
registry.config.handlers.dpeauth.details_path = 'valor'
registry.config.handlers.dpeauth.create_path = 'valor'
registry.config.handlers.dpeauth.token = 'valor'
    
16.05.2017 / 21:39
0

Configuration files are circumstantial. If in all your tests you are going to use them, you can create a confi.rb , or even fixture for it and make require in your specs. If it is in one test or another, use let(:config) or before :each .

link

link

link

    
16.05.2017 / 00:50