# Setting the flash in view helper tests

**URL:** <https://www.ruby-forum.com/t/setting-the-flash-in-view-helper-tests/178692>\
**Category:** Rails\
**Created:** [November 9, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/setting-the-flash-in-view-helper-tests/178692 "2009-11-09T18:25:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthonybaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c68b51/32.png) [@anthonybaker](https://www.ruby-forum.com/u/anthonybaker)\
**Post date:** [November 9, 2009, 6:25pm UTC](https://www.ruby-forum.com/t/setting-the-flash-in-view-helper-tests/178692/1 "2009-11-09T18:25:43Z")

</div>

Hello all,

I am trying to find a way to set the flash for a view helper test. The  
purpose of my view helper is to simplify rendering of flash messages,  
and I’d like to be able to test it by passing a mocked flash object to  
the helper method in my tests. I’m not quite sure how to do this,  
perhaps by mocking somehow?

Here was my first attempt that did not work:

context “flash\_messages” do  
setup do  
@flash = { :notice =\> "A notification message }  
@result = flash\_messages  
end

…  
end
