{"id":517,"date":"2022-08-30T15:02:40","date_gmt":"2022-08-30T15:02:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/how-do-you-mock-params-when-testing-a-rails-models-setter-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:02:40","modified_gmt":"2022-08-30T15:02:40","slug":"how-do-you-mock-params-when-testing-a-rails-models-setter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-do-you-mock-params-when-testing-a-rails-models-setter-collection-of-common-programming-errors\/","title":{"rendered":"How do you mock params when testing a Rails model&#39;s setter?-Collection of common programming errors"},"content":{"rendered":"<p>Can we see the whole stack trace? Where does it think String#stringify_keys! is being called?<\/p>\n<p>Also, params looks odd to me. Is tasks.build() expecting input like this: <code>[\"new_tasks_attribute\", {\"name\" =&gt; \"paint fence\"}]<\/code> ?<\/p>\n<p>If not, maybe you actually want Hash#each_key() instead of Hash#each()?<\/p>\n<p>Need more data. Also, you might consider a Ruby tag to accompany your Rails tag.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 20:03:26. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Can we see the whole stack trace? Where does it think String#stringify_keys! is being called? Also, params looks odd to me. Is tasks.build() expecting input like this: [&#8220;new_tasks_attribute&#8221;, {&#8220;name&#8221; =&gt; &#8220;paint fence&#8221;}] ? If not, maybe you actually want Hash#each_key() instead of Hash#each()? Need more data. Also, you might consider a Ruby tag to accompany [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=517"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/517\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}