Flashback plugin

Plugin details

Calling flashback in your functional test sometime after the TestRequest is instantiated and before your first call to an action, will allow you to access the discarded flash variables (those that were flashed) during the request processing. Specifically, it will allow you to access the Flash.now variables by name.

Websitehttp://glomp.rubyforge.org/flashback/ Repositoryhttp://glomp.rubyforge.org/svn/plugins/flashback/ Author Justin Knowlden Tags Tests LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://glomp.rubyforge.org/svn/plugins/flashback/

You will access these discarded variables similar to how you would access them in Flash.now, but this time via a _flashed_ method. For example:

  class FooController < ApplicationController
    def create
      ...
      flash.now[:error] = 'Whoops!' unless params[:foo][:baz]
      ...
    end
  end

  class FooControllerTest < ActionController::TestCase
    def test_create_should_set_some_flash_now_variable
      flashback
      get :create, :foo => {:bar => 'hello'}
      assert_equal 'Whoops!', flash.flashed[:error]
    end
  end



What you will not have access to via _flashed_ are the normal, inter-request Flash variables. This is because Flashback is only tracking those flash variables that are _discarded_ during the transaction, which includes all variables passed through Flash.now.

If you want _flashed_ available all of the time, then simply call flashback in the _setup_ method of your TestCase. There are likely better ways that I hope someone will tell me about, but I just wanted to get this plugin out-the-door.

The only caveat to Flashback is that if you define your own Flash instance and pass that to your various process methods (get, post, head, etc.), your flash will override Flashback's, rendering it useless.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: scott, 3 months ago