Module: Alchemy::TestSupport::ConfigStubbing
- Defined in:
- lib/alchemy/test_support/config_stubbing.rb
Overview
Allows you to stub the Alchemy configuration in your specs
Require and include this file in your RSpec config.
RSpec.configure do |config|
config.include Alchemy::TestSupport::ConfigStubbing
end
Instance Method Summary collapse
-
#stub_alchemy_config(hash) ⇒ Object
Stub a key from the Alchemy config.
- #stub_config(config, hash) ⇒ Object
Instance Method Details
#stub_alchemy_config(hash) ⇒ Object
Stub a key from the Alchemy config
18 19 20 |
# File 'lib/alchemy/test_support/config_stubbing.rb', line 18 def stub_alchemy_config(hash) stub_config(Alchemy.config, hash) end |
#stub_config(config, hash) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/alchemy/test_support/config_stubbing.rb', line 22 def stub_config(config, hash) hash.each do |key, value| if value.is_a?(Hash) stub_config(config.send(key), value) else allow(config).to receive(key).and_return(value) end end end |