# Question about rspec assigns

**URL:** <https://www.ruby-forum.com/t/question-about-rspec-assigns/76002>\
**Category:** Ruby\
**Created:** [November 15, 2006, 2:04am UTC](https://www.ruby-forum.com/t/question-about-rspec-assigns/76002 "2006-11-15T02:04:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agnathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@agnathan](https://www.ruby-forum.com/u/agnathan)\
**Post date:** [November 15, 2006, 2:04am UTC](https://www.ruby-forum.com/t/question-about-rspec-assigns/76002/1 "2006-11-15T02:04:34Z")

</div>

Hi folks,

I’m using rspec for a Rails project and keep seeing the “assigns” method  
in  
the “writing specs” portion of the documentation, yet I don’t see  
“assigns”  
in the rdoc and I can’t seem to find an explicit definition what it  
does.  
Would someone be able to tell me what exactly “assigns” does?

Thanks!  
Daniel

---

<div class="post-metadata">

**Author:** ![agnathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@agnathan](https://www.ruby-forum.com/u/agnathan)\
**Post date:** [November 15, 2006, 2:12am UTC](https://www.ruby-forum.com/t/question-about-rspec-assigns/76002/2 "2006-11-15T02:12:35Z")

</div>

On 11/14/06, Daniel H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi folks,
> 
> I’m using rspec for a Rails project and keep seeing the “assigns” method in  
> the “writing specs” portion of the documentation, yet I don’t see “assigns”  
> in the rdoc and I can’t seem to find an explicit definition what it does.  
> Would someone be able to tell me what exactly “assigns” does?

Assigns is a feature RSpec borrows from the regular Rails test/unit  
helpers.  
In a controller spec, assigns[:blah] points at the @blah instance  
variable.  
Useful for setting expectations on what the controller will do with  
your request.

Also, this is probably better suited for the RSpec mailing list.

---

<div class="post-metadata">

**Author:** ![agnathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/919ad9/32.png) [@agnathan](https://www.ruby-forum.com/u/agnathan)\
**Post date:** [November 15, 2006, 2:26am UTC](https://www.ruby-forum.com/t/question-about-rspec-assigns/76002/3 "2006-11-15T02:26:37Z")

</div>

Thanks!

Sorry for asking here - the rspec forum on rubyforge  
([http://rubyforge.org/forum/?group\_id=797](http://rubyforge.org/forum/?group_id=797)) was pretty barren, but now I  
see  
how to joing the mailing list - thanks again!

Daniel
