Basic Controller Rspecs


Suppose the following method is there in the controller

def new
  @post =

For this the corresponding spec will be as follows

describe "GET #new" do
  it "creates new instance of post" do
    get :new
    assigns(:post).should be_a_new(Post)

In the above code “get :new” line will get the new path of the controller and execute the corresponding method described in the controller. So that particular statement is very important for execution of the method and comparison of the output in the test.

View original post 458 more words

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: