[rspec-users] [rspec-rails] Configuring which ExampleGroup gets instantiated

Ilya P. iparips at gmail.com
Tue Nov 30 23:48:54 EST 2010


Hi all,

I've spent a fair bit of time googling but couldn't find the answer to
this question. Any insight would be greatly appreciated. Basically I'm
specking my ActionMailer instance & I would like to use
ControllerExampleGroup's method assigns(). How can I specify which
type of ExampleGroup rspec instantiates when I call describe() in my
spec?

My understanding is rspec-rails determines which type of ExampleGroup
to instantiate based on the directories that the specs are in. For
example it instantiates a ModelExampleGroup for specs in models/, or
ControllerExampleGroup for specs in controllers/.

Is there a way to specify the type of example group that gets
instantiated regardless of the directory the specs are in?

I recall that at some point in past I could supply a :type
=>:controller parameter to describe() method. I tried doing that for
my mailer spec but the example group I got was still
RSpec::Core::ExampleGroup.

Here is what I am using:

ruby 1.9
rails 3.0.1
rspec 2.0.1
rspec-rails 2.0.1

Thanks a lot,
Ilya.


More information about the rspec-users mailing list