以下formtastic形式複選框字段設置:使用水豚黃瓜測試服務,使得測試失敗,而:Formtastic複選框PARAMS通過水豚發送不同於通過實際應用
<%= semantic_form_for @store do |f| %>
<%= f.inputs do %>
<%= f.input :services, :as => :check_boxes, :collection => Service.all %>
<% end -%>
<% end -%>
正在發送壞params用於在實際應用發送正確的,這被罰款處理:
#cucumber steps using the boiler_plate capybara web_steps.rb:
Given a "Mail Order" service
...(steps for rest of the form)...
When I check "Mail Order"
And I press "Create Store"
Then I should see "Store was successfully created."
And I should see "Mail Order"
#params sent by cucumber
"store"=>{"services"=>["[\"4d8247ed7f5bfd2275000004\"]"]
#params sent by app on manual test
"store"=>{"services"=>["4d8247ed7f5bfd2275000004"]}
雖然HTML表單本身呈現同樣的方式在兩種情況下:
<input id="store_services_4d8247ed7f5bfd2275000004" name="store[services][]" type="checkbox" value="4d8247ed7f5bfd2275000004" />
似乎在請求params構建過程中,當由Cucumber/Capybara提交時,該字段的表單鍵/值對的解析方式會有所不同。
其他人碰到過嗎?
該解決方案可能應該變成一個「答案」 - 其他人可能會搜索(並找到)這個問題,但跳過它,認爲沒有解決方案。 – 2011-06-16 16:58:31
我找不到回答我自己的問題的方法。可能沒有足夠的特權?我在meta網站上搜索了這個問題的答案,但沒有運氣。 – oliverbarnes 2011-06-17 21:25:18
如果您已經登錄,您應該在這些評論下面有一個大框。如果這是你自己的問題,不要緊。 – 2011-06-18 20:34:36