Closed slhck closed 1 year ago
I'd suggest trying to use stub_const
to replace the Settings
constant with a test double.
See also Constant Stubbing in RSpec 2.11
I do this in rspec:
before do
allow(Settings.item).to receive(:sub_property).and_return('7')
end
Minitest
# Settings.some_boolean
Settings.stub :some_boolean, true do
# method_call
end
# Settings.app.some_boolean
Settings.app.stub :some_boolean, true do
# method_call
end
I would like to mock some settings temporarily for some Rspec tests.
How would I go about doing this?
When I do, inside a test:
This bleeds over to other tests rather than being local to a certain test.
I can do
Settings.reload_from_files
without any argument to clear all settings, but I'd rather not want to manually specify the default filenames for the various environments.