Skip to content

Commit 632226b

Browse files
committed
add specs for Settings.enabled?
1 parent d922dbc commit 632226b

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

spec/bashly/settings_spec.rb

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,73 @@
9797
end
9898
end
9999

100-
describe 'strict_string' do
100+
describe '::enabled?' do
101+
context 'when the value is always' do
102+
before { subject.enable_header_comment = 'always' }
103+
104+
it 'returns true' do
105+
expect(subject.enabled? :header_comment).to be true
106+
end
107+
end
108+
109+
context 'when the value is never' do
110+
before { subject.enable_header_comment = 'never' }
111+
112+
it 'returns false' do
113+
expect(subject.enabled? :header_comment).to be false
114+
end
115+
end
116+
117+
context 'when the value is production in a production env' do
118+
before do
119+
subject.enable_header_comment = 'production'
120+
subject.env = :production
121+
end
122+
123+
it 'returns true' do
124+
expect(subject.enabled? :header_comment).to be true
125+
end
126+
end
127+
128+
context 'when the value is production in a development env' do
129+
before do
130+
subject.enable_header_comment = 'production'
131+
subject.env = :development
132+
end
133+
134+
after { subject.env = nil }
135+
136+
it 'returns false' do
137+
expect(subject.enabled? :header_comment).to be false
138+
end
139+
end
140+
141+
context 'when the value is development in a production env' do
142+
before do
143+
subject.enable_header_comment = 'development'
144+
subject.env = :production
145+
end
146+
147+
it 'returns false' do
148+
expect(subject.enabled? :header_comment).to be false
149+
end
150+
end
151+
152+
context 'when the value is development in a development env' do
153+
before do
154+
subject.enable_header_comment = 'development'
155+
subject.env = :development
156+
end
157+
158+
after { subject.env = nil }
159+
160+
it 'returns true' do
161+
expect(subject.enabled? :header_comment).to be true
162+
end
163+
end
164+
end
165+
166+
describe '::strict_string' do
101167
context 'when strict is true' do
102168
before { subject.strict = true }
103169

0 commit comments

Comments
 (0)