Suppose the following method is there in the controller
def new @post = Post.new end
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) end end
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