当我登录到我的应用程序时,服务器会向我发送回 cookie(凭据和某些应用程序的 cookie):
Response sent 170 bytes of Cookie data:
Set-Cookie: user_credentials=val; path=/; HttpOnly; Secure
Response sent 554 bytes of Cookie data:
Set-Cookie: _app_session=otherVal; path=/; HttpOnly; Secure
...然后重定向到主页;
Cookie 包括一些标志:例如httpOnly
、Secure
等。
如何测试 cookie 是否包含带有 Rspec 的那些标志?
至少我在哪里可以找到那些饼干?
it "should generate cookies with proper flags" do
params = Factory.attributes_for(:user,
:username => "uname",
:password => "upass"
)
# login
post 'create', params
response.should redirect_to home_url # => pass
puts "response cookie = #{response.cookies.inspect}" # => {} // no cookies in response, why?
end