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

Instance Method Details

#stub_alchemy_config(key, value) ⇒ Object

Stub a key from the Alchemy config

Parameters:

  • key (Symbol)

    The configuration key you want to stub

  • value (Object)

    The value you want to return instead of the original one


18
19
20
21
22
23
24
25
26
# File 'lib/alchemy/test_support/config_stubbing.rb', line 18

def stub_alchemy_config(key, value)
  allow(Alchemy::Config).to receive(:get) do |arg|
    if arg == key
      value
    else
      Alchemy::Config.show[arg.to_s]
    end
  end
end