This post was originally written by Brian Takita.
I just released Cacheable Flash 0.1.4. This version includes test helpers so you can easily test your cache messages. It works by allowing you to make assertions on the flash cookie.
Here is a test/unit example:
require "cacheable_flash/test_helpers" class TestController < ActionController::Base def index flash["notice"] = "In index" end end class ControllerTest < Test::Unit::TestCase include CacheableFlash::TestHelpers def setup @controller = TestController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_cacheable_flash_action get :index asset_equal "In index", flash_cookie["notice"] end end
Here is a rspec example:
require "cacheable_flash/test_helpers" class TestController < ActionController::Base def index flash["notice"] = "In index" end end describe TestController, "#index" do include CacheableFlash::TestHelpers it "writes to the flash cookie" do get :index flash_cookie["notice"].should == "In index" end end
You can install Cacheable Flash by running:
ruby script/plugin install svn://rubyforge.org/var/svn/pivotalrb/cacheable_flash/trunk
About the AuthorMore Content by Brian Takita