From c53194dff361859cedfd22092c58679a203c374e Mon Sep 17 00:00:00 2001 From: Chris LaRose Date: Sun, 20 Dec 2020 13:10:49 -0800 Subject: [PATCH] Run tests in random order (#298) --- .rspec | 3 ++- spec/config_env_spec.rb | 17 +++++++++-------- spec/config_spec.rb | 9 +++------ spec/options_spec.rb | 7 +++---- spec/spec_helper.rb | 1 + 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.rspec b/.rspec index 0b23933f..81e6e158 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --color ---format progress \ No newline at end of file +--format progress +--order random diff --git a/spec/config_env_spec.rb b/spec/config_env_spec.rb index de7cf1ee..65e7da8b 100644 --- a/spec/config_env_spec.rb +++ b/spec/config_env_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' describe Config::Options do + before :each do + Config.reset + end + context 'when overriding settings via ENV variables is enabled' do let(:config) do Config.load_files "#{fixture_path}/settings.yml", "#{fixture_path}/multilevel.yml" end - before :all do - Config.use_env = true - end - after :all do Config.use_env = false end @@ -17,10 +17,11 @@ before :each do ENV.clear - Config.env_prefix = nil - Config.env_separator = '.' - Config.env_converter = :downcase - Config.env_parse_values = true + Config.use_env = true + Config.env_prefix = nil + Config.env_separator = '.' + Config.env_converter = :downcase + Config.env_parse_values = true end it 'should add new setting from ENV variable' do diff --git a/spec/config_spec.rb b/spec/config_spec.rb index ad7da5c6..71ca7411 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' describe Config do + before :each do + Config.reset + end it "should get setting files" do config = Config.setting_files("root/config", "staging") @@ -349,15 +352,12 @@ context 'using knockout_prefix' do context 'in configuration phase' do it 'should be able to assign a different knockout_prefix value' do - Config.reset Config.knockout_prefix = '--' expect(Config.knockout_prefix).to eq('--') end it 'should have the default knockout_prefix value equal nil' do - Config.reset - expect(Config.knockout_prefix).to eq(nil) end end @@ -389,15 +389,12 @@ context 'using overwrite_arrays' do context 'in configuration phase' do it 'should be able to assign a different overwrite_arrays value' do - Config.reset Config.overwrite_arrays = false expect(Config.overwrite_arrays).to eq(false) end it 'should have the default overwrite_arrays value equal false' do - Config.reset - expect(Config.overwrite_arrays).to eq(true) end end diff --git a/spec/options_spec.rb b/spec/options_spec.rb index 2ec7acab..8f49a8d2 100644 --- a/spec/options_spec.rb +++ b/spec/options_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' describe Config::Options do + before :each do + Config.reset + end context 'when Settings file is using keywords reserved for OpenStruct' do let(:config) do @@ -127,8 +130,6 @@ end context 'when fail_on_missing option' do - before { Config.reset } - context 'is set to true' do before { Config.setup { |cfg| cfg.fail_on_missing = true } } @@ -190,8 +191,6 @@ end context 'when merge_hash_arrays options' do - before { Config.reset } - context 'is set to true' do before { Config.setup { |cfg| cfg.overwrite_arrays = false diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7aaa9bcd..4e802328 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -77,6 +77,7 @@ def self.reset self.overwrite_arrays = true self.schema = nil self.validation_contract = nil + self.fail_on_missing = false instance_variable_set(:@_ran_once, false) end end