# What does the 'it' do?

**URL:** <https://www.ruby-forum.com/t/what-does-the-it-do/149688>\
**Category:** Ruby\
**Created:** [September 28, 2008, 8:20am UTC](https://www.ruby-forum.com/t/what-does-the-it-do/149688 "2008-09-28T08:20:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![timr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3e96dc/32.png) [@timr](https://www.ruby-forum.com/u/timr)\
**Post date:** [September 28, 2008, 8:20am UTC](https://www.ruby-forum.com/t/what-does-the-it-do/149688/1 "2008-09-28T08:20:53Z")

</div>

I came across the following code (see below). As President Clinton  
famously said, “It depends on what the definition of ‘it’ is.” I am  
hoping someone can explain how ‘it’ is being used. I have come across  
this ‘it…string…do’ construct before, but I didn’t understand it  
then either.

describe IowaRubyBrigade do  
before do  
@irb = Array.new  
end

it “should be a user group” do  
@irb.should be\_a\_kind\_of(UserGroup)  
end

it “should meet monthly” do  
@irb.meeting\_time.should ==  
‘second Thursday of every month’  
end

it “should be fun” do  
@irb.should be\_fun  
end  
end

When you ri it, you get:

* * *

## Spec::Example::ExampleGroupMethods#it it(description=nil, &implementation)

```
 Creates an instance of Spec::Example::Example and adds it to a
 collection of examples of the current example group.

 (also known as specify)

```

But the documentation on Spec is difficult to find. Please educate me.  
Thanks,  
Tim

---

<div class="post-metadata">

**Author:** ![timr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3e96dc/32.png) [@timr](https://www.ruby-forum.com/u/timr)\
**Post date:** [September 28, 2008, 10:55am UTC](https://www.ruby-forum.com/t/what-does-the-it-do/149688/2 "2008-09-28T10:55:19Z")

</div>

On 28.09.2008 08:18, timr wrote:

> ```
> @irb.should be_fun
> collection of examples of the current example group.
> 
> (also known as specify)
> 
> ```
> 
> But the documentation on Spec is difficult to find. Please educate me.  
> Thanks,  
> Tim

“it” is a method which apparently does what your RI doc says. Most  
likely it saves the block somewhere for later execution (i.e. in order  
to perform the test).

Fur further information you probably want to look at RSpec  
documentation, e.g. [RSpec documentation](http://rspec.info/documentation/)

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![timr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3e96dc/32.png) [@timr](https://www.ruby-forum.com/u/timr)\
**Post date:** [September 28, 2008, 2:00pm UTC](https://www.ruby-forum.com/t/what-does-the-it-do/149688/3 "2008-09-28T14:00:30Z")

</div>

Last winter, I wrote a series of blog posts dissecting the rspec code to  
see  
what describe/it do, as well as what happens when the examples are run.  
It  
is from the perspective of a fairly new ruby person (as I was at the  
time,  
and, I guess, still am), but here’s links. I can’t say whether they will  
help you, or not, since I mostly wrote them for myself:  
describe  
Part I -  
[http://www.coreyhaines.com/coreysramblings/2007/12/15/ARubyNewbieLooksThroughRSpecPartIIDescribe.aspx](http://www.coreyhaines.com/coreysramblings/2007/12/15/ARubyNewbieLooksThroughRSpecPartIIDescribe.aspx)  
Part II -  
[http://www.coreyhaines.com/coreysramblings/2007/12/22/ARubyNewbieLooksThroughRSpecPartIIIDescribeRedux.aspx](http://www.coreyhaines.com/coreysramblings/2007/12/22/ARubyNewbieLooksThroughRSpecPartIIIDescribeRedux.aspx)

it  
[http://www.coreyhaines.com/coreysramblings/2007/12/27/ARubyNewbieLooksThroughRSpecPartIVIt.aspx](http://www.coreyhaines.com/coreysramblings/2007/12/27/ARubyNewbieLooksThroughRSpecPartIVIt.aspx)

run  
[http://www.coreyhaines.com/coreysramblings/2007/12/27/ARubyNewbieLooksThroughRSpecPartIVRunI.aspx](http://www.coreyhaines.com/coreysramblings/2007/12/27/ARubyNewbieLooksThroughRSpecPartIVRunI.aspx)

Hope they can help explain it a bit.  
-Corey

On Sun, Sep 28, 2008 at 4:54 AM, Robert K.

---

<div class="post-metadata">

**Author:** ![timr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/3e96dc/32.png) [@timr](https://www.ruby-forum.com/u/timr)\
**Post date:** [September 28, 2008, 2:08pm UTC](https://www.ruby-forum.com/t/what-does-the-it-do/149688/4 "2008-09-28T14:08:08Z")

</div>

Just a follow-up; I started reading through them, and the Part I of  
describe  
is for an older version, so it can be skipped.
