Minitest data submission format for datetime

A controller action parses an optional datetime collection select with
if params[:individual]["birth_date_ui(1i)"].present?

However when testing one cannot format the request as:

post individuals_url, params: { individual: { birth_date_ui(1i): 1990, birth_date_ui(2i): 12, [...] } }

as this does not appreciate handling the colon after parenthesis: syntax error, unexpected ':', expecting => (SyntaxError) ..., birth_date_ui(1i): 1990, birth_date_ui(2i): 12

Yet providing a different syntax of parameters,

birth_date_ui: - 48.years

the above block of data is deemed not covered by the coverage gem. It also submit a date string not a datetime sting.

How can the test be written to properly verify the presence and subsequent processing of datetime parameters?


  • You may also create symbols by interpolation:

    :"my_symbol#{1 + 1}"

    { "birth_date_ui(1i)": 1990, "birth_date_ui(2i)": 12 }