Problem running test controller in rails 4

1

Good afternoon,

I generated a scaffold of a class of mine, example User. When running the tests I came across the following failure:

Minitest::Assertion: "User.count" didn't change by 1.
 Expected: 3
  Actual: 2
test/controllers/users_controller_test.rb:20:in 'block in <class:UsersControllerTest>' 

The code for this error is:

test "should create user" do
  assert_difference('User.count') do
    post :create, user: { name: 'teste', password: 'secret', password_confirmation: 'secret' }
  end
  assert_redirected_to user_path(assigns(:user))
end

This is the code generated by scaffold, I just changed the name reference.

As far as I can tell, create is not running. I already put a brakpoint in the controller's create but not there.

Am I doing something wrong?

Thanks in advance for your help

    
asked by anonymous 30.07.2014 / 21:59

1 answer

1

I was able to solve the problem,

I had forgotten to put the user in the session

    
31.07.2014 / 14:29