Selecting a radio button with Rspec
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm currently writing a test for a form using RSpec, and I was wondering how I'd go about selecting a radio button, given the form below: <%=form_for(@whatever) do|f|%> <%=f.label :option, "TRUE" %> <%=f.radio_button :option, true %> <%=f.label :option, "FALSE" %> <%=f.radio_button :morning, false %> <%=f.submit "SAVE" %> <% end %> I want my test to look something like: describe "with valid options selected" do before do #CODE TO SELECT A RADIO BUTTON click_button "SAVE" end end 回答1: describe "with valid info" do before do choose('True')