rails rspec, error in post: create, params require

1

I'm starting the rspec tests in 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've already created the 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, thanks!

    
asked by anonymous 11.04.2017 / 16:33

1 answer

1

Does

post :create, params: { lancamento: attributes_for(:lancamento) }, format: :js, xhr: true

and should resolve your issue.

And as a suggestion, do not program in Portuguese. Reasons: link

    
11.04.2017 / 16:48