From b9841467c20670c82b5378b1af978b160d4dfdcb Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Thu, 11 Jan 2024 09:54:56 -0500 Subject: [PATCH] Disable strict in tests for now --- lib/flipper/engine.rb | 4 ++-- spec/flipper/engine_spec.rb | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/flipper/engine.rb b/lib/flipper/engine.rb index 6b30d571e..6f853fdc8 100644 --- a/lib/flipper/engine.rb +++ b/lib/flipper/engine.rb @@ -9,8 +9,8 @@ def self.default_strict_value elsif Rails.env.production? false else - # Warn for now. Future versions will default to :raise in development and test - :warn + # Warn in development for now. Future versions may default to :raise in development and test + Rails.env.development? && :warn end end diff --git a/spec/flipper/engine_spec.rb b/spec/flipper/engine_spec.rb index e6260f240..cbff2bade 100644 --- a/spec/flipper/engine_spec.rb +++ b/spec/flipper/engine_spec.rb @@ -73,23 +73,31 @@ expect(adapter).to be_instance_of(Flipper::Adapters::Memory) end - it "defaults to strict=false in RAILS_ENV=production" do - Rails.env = "production" + it "defaults to strict=:warn in RAILS_ENV=development" do + Rails.env = "development" subject - expect(config.strict).to eq(false) - expect(adapter).to be_instance_of(Flipper::Adapters::Memory) + expect(config.strict).to eq(:warn) + expect(adapter).to be_instance_of(Flipper::Adapters::Strict) end - %w(development test).each do |env| + %w(production test).each do |env| it "defaults to strict=warn in RAILS_ENV=#{env}" do Rails.env = env expect(Rails.env).to eq(env) subject - expect(config.strict).to eq(:warn) - expect(adapter).to be_instance_of(Flipper::Adapters::Strict) - expect(adapter.handler).to be(:warn) + expect(config.strict).to eq(false) + expect(adapter).to be_instance_of(Flipper::Adapters::Memory) end end + + it "defaults to strict=warn in RAILS_ENV=development" do + Rails.env = "development" + expect(Rails.env).to eq("development") + subject + expect(config.strict).to eq(:warn) + expect(adapter).to be_instance_of(Flipper::Adapters::Strict) + expect(adapter.handler).to be(:warn) + end end context 'cloudless' do