I am using Rails 6 with Ruby 2.5.5. I am trying to write an example for a controller method and something is baffling me for the past few hours:
Why does this:
post :create, params: { purchases: [{ board_id: 1, squares: [ [3,4] ] }] }, format: :json
pass these params:
POST { "purchases": [{"board_id"=>"16", "squares"=>[["3"], ["4"]] }] }
Note how [3,4] is being turned into [["3"], ["4"]]. It works fine in the browser, just not with rspec.
According to https://github.com/rspec/rspec-rails/issues/985 this fixed it:
post :create, params: { purchases: [{ board_id: 1, squares: [ [3,4] ] }] }, as: :json
Thank you Rspec!