I have the following methods in my controller:
def create @user = User.new(params[:user]) if @user.save redirect_to log_in_path, notice: 'Signed up!' else render "new" end end def destroy @user = User.find(params[:id]) @user.destroy redirect_to users_path, notice: 'User was deleted.' end and specs:
describe "POST 'create'" do it "should allow create user" do @user = Factory(:user) post 'create', :id => @user response.should be_success end describe "DELETE 'destroy'" do it "should delete the user" do @user = Factory(:user) delete "destroy", :id => @user response.should redirect_to users_path end end I don't understand why the test for create method is passing even if there is a redirect right after the object is saved. if i set:
response.should redirect_to log_in_path as expectation the test will fail, same for destroy method, if I switch expectation to:
response.should be_success it will fail. Any suggestions? Thanks