Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
Cacheable Flash 0.1.4 — Test Helpers

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

See the Cacheable Flash blog post, Show Flash Messages on Cached Pages, and the README for more information.

Comments
  1. tyler.cope@overlay.tv says:

    This looks great. You wouldn’t happen to have another location where I could find the plugin, would you? RubyForge is down for a hardware upgrade…

    Tyler

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *