diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-02 08:54:25 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-04-02 08:54:25 +0000 |
commit | ce96c5b30b52a1b2d1628d6e605e7989f9eea023 (patch) | |
tree | b70ff91977e03e3fac267392a955bce4660f5da5 /actionpack/lib/action_controller/assertions | |
parent | 1ba1779754965da9b0cff73d37905b71928d3598 (diff) | |
download | rails-ce96c5b30b52a1b2d1628d6e605e7989f9eea023.tar.gz rails-ce96c5b30b52a1b2d1628d6e605e7989f9eea023.tar.bz2 rails-ce96c5b30b52a1b2d1628d6e605e7989f9eea023.zip |
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
Diffstat (limited to 'actionpack/lib/action_controller/assertions')
-rw-r--r-- | actionpack/lib/action_controller/assertions/action_pack_assertions.rb | 13 |
1 files changed, 11 insertions, 2 deletions
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 --------------------------------------------------- |