# Testing your Controller, using RSpec

**URL:** <https://discuss.rubyonrails.org/t/testing-your-controller-using-rspec/36047>\
**Category:** rubyonrails-talk\
**Created:** [November 5, 2008, 4:53am UTC](https://discuss.rubyonrails.org/t/testing-your-controller-using-rspec/36047 "2008-11-05T04:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torm3nt](https://avatars.discourse-cdn.com/v4/letter/t/cab0a1/32.png) [@Torm3nt](https://discuss.rubyonrails.org/u/Torm3nt)\
**Post date:** [November 5, 2008, 4:53am UTC](https://discuss.rubyonrails.org/t/testing-your-controller-using-rspec/36047/1 "2008-11-05T04:53:54Z")

</div>

If anyone is interested, I've written up a fairly basic tutorial going over testing some features of your controllers, using RSpec. Am looking for comments/constructive criticism on the article and if there's anything you'd like to see me write, am all ears! 🙂

Article is here: [http://www.kirkbushell.com/articles/testing-using-rspec-part-2-the-controller](http://www.kirkbushell.com/articles/testing-using-rspec-part-2-the-controller)

Enjoy, and feel free to comment!

---

<div class="post-metadata">

**Author:** ![Thorsten\_Muller2](https://avatars.discourse-cdn.com/v4/letter/t/8edcca/32.png) [@Thorsten\_Muller2](https://discuss.rubyonrails.org/u/Thorsten_Muller2)\
**Post date:** [November 5, 2008, 11:25am UTC](https://discuss.rubyonrails.org/t/testing-your-controller-using-rspec/36047/2 "2008-11-05T11:25:29Z")

</div>

Looks really good for a start.

Depending on the knowledge of the intended audience it may help some people if you would explain what stubbing means. It's an important concept of rspec and extremely helpful in many situations. Could even get it's own chapter.

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [November 5, 2008, 11:32am UTC](https://discuss.rubyonrails.org/t/testing-your-controller-using-rspec/36047/3 "2008-11-05T11:32:43Z")

</div>

A few issues:

- You talk about TDD at its primitive finest, but you actually wrote code before the specs...

- describe :login is not a clear description

- Your users\_controller is not designed restfully

- The way you set session[:user] in the controller uses bad coding practice

Beside that, trying to teach people is also a good way to learn.
