[rspec-users] get to a different controller

Phillip Koebbe phillipkoebbe at gmail.com
Thu Jan 7 10:03:48 EST 2010

To all involved,

Great discussion! Thank you so much for taking the time out of your
busy lives to contribute. Please believe me when I say that I
appreciate it *very* much!

Here is the latest version of my code:


I like the idea of shared examples (trying to use the right
terminology!). It took me a bit to realize that the shared examples
have to be required somewhere. [I didn't see anything on rspec.info
about it, but did not consult the RSpec Book. Maybe it's there.] I
decided on the shared_controller_examples.rb file for now, but might
change it later. I have some further refactoring to do regarding the
chain of requiring files, but I'm pretty pleased at the moment.

I can go both ways on where to test implementation: at the source or
the execution. I worked on a Rails project last year that used Single
Table Inheritance, and there was quite a bit of functionality defined
in the base class with some additional functionality in the derived
classes. We opted to test the different parts where they were, not
where they would be exercised. It worked out well there. But in this
case, I am convinced that shared examples are the way to go. I do
*not* like creating classes in my specs just to run a test. That's
akin to having routes or actions in my application that would be used
only during testing. I can't bring myself to do it.


More information about the rspec-users mailing list