Skip to content

Commit 896c36d

Browse files
committed
dry up more tests
1 parent a03fead commit 896c36d

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

spec/lib/secure_headers/headers/cookie_spec.rb

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -141,34 +141,15 @@ module SecureHeaders
141141
end.to raise_error(CookiesConfigError)
142142
end
143143

144-
it "raises an exception when SameSite lax and strict enforcement modes are configured with booleans" do
145-
expect do
146-
Cookie.validate_config!(samesite: { lax: true, strict: true})
147-
end.to raise_error(CookiesConfigError)
148-
end
149-
150-
it "raises an exception when SameSite lax and none enforcement modes are configured with booleans" do
151-
expect do
152-
Cookie.validate_config!(samesite: { lax: true, none: true})
153-
end.to raise_error(CookiesConfigError)
154-
end
155-
156-
it "raises an exception when SameSite strict and none enforcement modes are configured with booleans" do
157-
expect do
158-
Cookie.validate_config!(samesite: { strict: true, none: true})
159-
end.to raise_error(CookiesConfigError)
160-
end
161-
162-
it "raises an exception when SameSite none and lax enforcement modes are configured with booleans" do
163-
expect do
164-
Cookie.validate_config!(samesite: { none: true, lax: true})
165-
end.to raise_error(CookiesConfigError)
166-
end
167-
168-
it "raises an exception when SameSite none and strict enforcement modes are configured with booleans" do
169-
expect do
170-
Cookie.validate_config!(samesite: { none: true, strict: true})
171-
end.to raise_error(CookiesConfigError)
144+
cookie_options = %i(none lax strict)
145+
cookie_options.each do |flag|
146+
(cookie_options - [flag]).each do |other_flag|
147+
it "raises an exception when SameSite #{flag} and #{other_flag} enforcement modes are configured with booleans" do
148+
expect do
149+
Cookie.validate_config!(samesite: { flag => true, other_flag => true})
150+
end.to raise_error(CookiesConfigError)
151+
end
152+
end
172153
end
173154

174155
it "raises an exception when SameSite lax and strict enforcement modes are configured with booleans" do

0 commit comments

Comments
 (0)