From ce96c5b30b52a1b2d1628d6e605e7989f9eea023 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 2 Apr 2005 08:54:25 +0000 Subject: Added assert_no_cookie and fixed assert_cookie_equal to deal with non-existing cookies #979 [bitsweat] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1065 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../action_controller/assertions/action_pack_assertions.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller/assertions') diff --git a/actionpack/lib/action_controller/assertions/action_pack_assertions.rb b/actionpack/lib/action_controller/assertions/action_pack_assertions.rb index d1d5cafc08..9bbcc5b83f 100644 --- a/actionpack/lib/action_controller/assertions/action_pack_assertions.rb +++ b/actionpack/lib/action_controller/assertions/action_pack_assertions.rb @@ -63,10 +63,19 @@ module Test #:nodoc: # -- cookie assertions --------------------------------------------------- + def assert_no_cookie(key = nil, message = nil) + response = acquire_assertion_target + actual = response.cookies[key] + msg = build_message(message, " not expected in cookies['?']", actual, key) + assert_block(msg) { actual.nil? or actual.empty? } + end + def assert_cookie_equal(expected = nil, key = nil, message = nil) response = acquire_assertion_target - msg = build_message(message, " expected in cookies['?'] but was ", expected, key, response.cookies[key.to_s].first) - assert_block(msg) { expected == response.cookies[key.to_s].first } + actual = response.cookies[key] + actual = actual.first if actual + msg = build_message(message, " expected in cookies['?'] but was ", expected, key, actual) + assert_block(msg) { expected == actual } end # -- flash assertions --------------------------------------------------- -- cgit v1.2.3