[rspec-users] Driving Out A View - Layouts and Sessions?

Stephen Eley sfeley at gmail.com
Sat Jun 6 19:08:57 EDT 2009

On Sat, Jun 6, 2009 at 1:01 AM, Lee<Lee.Longmore at googlemail.com> wrote:
> When I execute this, it complains of a missing method "sub_menu". This
> method, along with others such as "main_menu", are called within the
> layout. Unlike "main_menu" which is defined in my
> "application_helper.rb" file, "sub_menu" is defined in the helper file
> for the controller "contexts". How do I get the spec to "see" this
> file and its contents when executed? I think It's seeing "main_menu".

Just require it and then include it.  A "describe" block is really
just a prettified form of class definition, so you can include any
modules you like in it.

Although (warning: continued smartassery here) I'm also wondering why
it's a good idea to call a method defined in a specific controller's
helper from a global layout.  Is this layout only used by that
controller?  If not, why isn't the method in application helpers?

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list