Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Bloggerdome Trippledown


The ANONYMOUS controller CLASS created in a controller spec is like before(:all), not before(:each)

If you create a controller inside your controller spec, it will be the same anonymous class for all of your tests inside your controller spec. Beware of test pollution if you have class attributes on your controller.

  1. huh says:

    I don’t see that. From two tests putsing the controller:


    You mention class attributes, those are just that, class attributes. They’re instance independent. Modifying them will affect all tests, rspec cannot magically reset class attributes. Look into stubbing class attributes rather than modifying them or use instances.

    • Hi, sorry for the confusion – I’ve update the blog post, I was referring to the anonymous controller class created when you use the `controller(SomeController)` syntax inside a controller spec. It will create a single controller class that will be used across all the tests, instead of recreating the anonymous at the beginning of each test run.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *