Rails rspec, post error :create, params require

Asked

Viewed 95 times

1

I’m starting rspec tests on Rubyonrails and I’m having a problem testing my controller’s create:

it "creates lançamento" do
  post :create, params: attributes_for(:lancamento), format: :js, xhr: true
  expect(Lancamento.count).to eq(1)
end

I already created Factory with Factorygirl. The error is as follows:

1) LancamentosController testa cadastro lançamento creates lançamento
 Failure/Error: params.require(:lancamento).permit(Lancamento.fields)

 ActionController::ParameterMissing:
   param is missing or the value is empty: lancamento

Any help is welcome, thank you!

1 answer

1


  • Solved! thanks, only now it stops at no expect returning 0.

  • Debug your controller, because it might fall into save Else for some validation.

  • Exactly, validation, I’ll arrange the launch Factory. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.