Daniel Daniel - 1 year ago 40
Ruby Question

what does the "it" keyword do in RSpec?

I'm following the rails3tutorial and I don't understand the meaning of the "it" keyword when doing some testing as follows:

require 'spec_helper'

describe UsersController do

describe "GET 'new'" do
it "should be successful" do
get 'new'
response.should be_success

it "should have the right title" do
get 'new'
response.should have_selector("title", :content => "Sign up")

code fragment comes from: http://ruby.railstutorial.org/chapters/filling-in-the-layout#top listing 5.26

Answer Source

It's not a Ruby keyword, it's part of the Rspec framework.

it contains the code examples that illustrate the facet of behavior being defined. It is comprised of two main parts: the description string and the code example, in the do/end block.