How to test Controller properly using Devise with Rspec?

Up vote 0 down vote favorite share g+ share fb share tw.

I want to start testing my controllers, however I'm new on this stage (testing) The first controller I want to be tested is my UsersController. Here's the controller code: class UsersController!request. Xhr?

) end def turns_moderator @user = User. Find(params:id). Moderator!

Respond_with(@user, :layout =>!request. Xhr? ) end def turns_user @user = User.

Find(params:id). User! Respond_with(@user, :layout =>!request.

Xhr? ) end end It's pretty basic but I have 3 actions that I make use of Ajax requests. For now, I have the following tests: require 'spec_helper' describe UsersController do include Devise::TestHelpers it "should get #index" do get 'index' response.

Should be_success end context "should get #show" do before { @user = FactoryGirl. Create(:user) } get 'show', :id => @user response. Should be_success end it "should DELETE #destroy" do delete 'destroy' response.

Should be_success end end Is this the correctt way of testing controllers? I appreciate any help. Thank you.

Ajax ruby-on-rails-3 rspec2 link|improve this question asked Apr 1 at 17:38Kleber S.1,073313 96% accept rate.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions