Peel me a Grape :: We make things work

We Make Things Work :: Blog

flash.now sets a flash only available for the current action. Controller/Functional testing flash.now can be problematic. This is now fixed on edge rails.

Previously one approach was to stub out the sweep method on flash in your tests.

Here’s how to do that nicely if you’re using rspec. Apply a global before block to all controller behaviours, a handy thing to know about.

Spec::Runner.configure do |config|
  config.before(:each, :behaviour_type => :controller) do
    @controller.instance_eval { flash.stub!(:sweep) }
  end
end
blog comments powered by Disqus