Testing a module that is included in a Controller

I am upgrading an existing app and have a lib/ module that is included in various controllers. Some of the methods in the module set flash.notice when they encounter an error.

How do I expose that method in my spec? Right now all I get is:

undefined local variable or method `flash' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000004084b08>

I’ve tried including various Rails modules (e.g., ActionDispatch) as well defining it myself in the spec, none of which work.

@JESii I’d read up on RSpec’s anonymous controllers; I think that’s the route you’ll want to go down. Good luck!

Thanks, Josh… That was what I needed to get me to re-think the problem. Turns out all I needed to do was move the spec file from spec/lib/… to spec/controllers/… and it all worked perfectly