[rspec-users] Modules will no longer be automatically included in RSpec version 1.1.4

Tom Stuart tom at experthuman.com
Tue May 27 03:01:11 EDT 2008


On 27 May 2008, at 01:22, Tim Glen wrote:
>>   whiz_banger = Object.new
>>   whiz_banger.extend WhizBangModule
> I like that as far as it goes, but I'm wondering if there's a way to  
> take it one step further and actually have it extend the typical  
> controller functionality - some of my methods make use of the  
> session, or set some assigns, for instance. I'd love to be able to  
> test it as if it were in a controller already

I suspect that the conventional answer is to mock the pieces of  
"typical controller functionality" you're relying on, so that 1.  
you're speccing your module in isolation from any other code, instead  
of trying to exercise two things at once, and 2. you're explicitly  
specifying (and exercising) the interface between your module and its  
host class instead of making a whole bunch of invisible assumptions.

Cheers,
-Tom


More information about the rspec-users mailing list