From 632226be54e1e0e0247b8ae3663312afca4613c8 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Wed, 18 Dec 2024 08:21:24 +0000 Subject: [PATCH] add specs for Settings.enabled? --- spec/bashly/settings_spec.rb | 68 +++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/spec/bashly/settings_spec.rb b/spec/bashly/settings_spec.rb index 1cf3935ee..07a513cb1 100644 --- a/spec/bashly/settings_spec.rb +++ b/spec/bashly/settings_spec.rb @@ -97,7 +97,73 @@ end end - describe 'strict_string' do + describe '::enabled?' do + context 'when the value is always' do + before { subject.enable_header_comment = 'always' } + + it 'returns true' do + expect(subject.enabled? :header_comment).to be true + end + end + + context 'when the value is never' do + before { subject.enable_header_comment = 'never' } + + it 'returns false' do + expect(subject.enabled? :header_comment).to be false + end + end + + context 'when the value is production in a production env' do + before do + subject.enable_header_comment = 'production' + subject.env = :production + end + + it 'returns true' do + expect(subject.enabled? :header_comment).to be true + end + end + + context 'when the value is production in a development env' do + before do + subject.enable_header_comment = 'production' + subject.env = :development + end + + after { subject.env = nil } + + it 'returns false' do + expect(subject.enabled? :header_comment).to be false + end + end + + context 'when the value is development in a production env' do + before do + subject.enable_header_comment = 'development' + subject.env = :production + end + + it 'returns false' do + expect(subject.enabled? :header_comment).to be false + end + end + + context 'when the value is development in a development env' do + before do + subject.enable_header_comment = 'development' + subject.env = :development + end + + after { subject.env = nil } + + it 'returns true' do + expect(subject.enabled? :header_comment).to be true + end + end + end + + describe '::strict_string' do context 'when strict is true' do before { subject.strict = true }