Ruby on rails 4 无法选中水豚中的复选框

Ruby on rails 4 无法选中水豚中的复选框,ruby-on-rails-4,checkbox,rspec,capybara,Ruby On Rails 4,Checkbox,Rspec,Capybara,我刚刚做了一个save_和open_页面,下面是我试图点击进行集成测试的html <input id="tos" name="tos" type="checkbox" value="{:id=>"tos"}"> <label for="tos">I have read and agree to the <a href="/termsofservice" style="color:#428bca" target="_blank">Terms of Serv

我刚刚做了一个save_和open_页面,下面是我试图点击进行集成测试的html

<input id="tos" name="tos" type="checkbox" value="{:id=>"tos"}">
<label for="tos">I have read and agree to the <a href="/termsofservice" style="color:#428bca" target="_blank">Terms of Service</a>.</label>
到目前为止,每次尝试之后,错误消息都是

Failure/Error: fill_in 'inventory_1', :with => 1
 Capybara::ElementNotFound:
   Unable to find field "inventory_1"

因为这反映了当点击按钮“借出”时,用户不会被引导到有库存的页面借出物品,因为他们会重新呈现/原始页面,并通过“保存”和“打开”页面确认错误,说明在继续之前必须同意服务条款

好了,开始工作了。。。也许这充其量只是一个坏的开发实践的提醒。在我写完页面的代码之后,我写了我的测试,我知道。。。。在本例中,当我编写测试并写出check‘tos’时,我返回到视图并将id‘tos’添加到check_box_标记中。这就是错误所在,check_-box_标记的第二个参数是值,因此通过添加,我使check_-box_标记的值始终为tos,而不是1(如果选中)和0(如果未选中)


基本上,在规范中,如果在视图中没有显示任何尝试的错误消息,那么选中“tos”就可以了。尝试page.checktos并显示输出。尝试了,没有工作,我发布了更多上下文和错误消息,很抱歉我遗漏了这些,因为在这种情况下它似乎没有太大帮助。
find(:xpath, "//*[@id='tos']").set(true)
check 'tos'
find("#tos").set(true)
check 'I have read and agree to the Terms of Service'
check 'I have read and agree to the "<a href="/termsofservice" style="color:#428bca" target="_blank">Terms of Service</a>".'            
find(:css, "#tos[value='{:id=>&quot;tos&quot;}']").set(true)
find(:css, "#tos[value='{:id=>'tos'}']").set(true)
      describe "something" do

        before do
          visit '/original'
          page.check("tos")
          fill_in 'signup_email1', :with => "test@example.com"
          click_button 'lend'
          save_and_open_page
          fill_in 'inventory_1', :with => 1
          click_button 'submit_lend'
        end

        it "should achieve some result" do
        ...
        end

      end
Failure/Error: fill_in 'inventory_1', :with => 1
 Capybara::ElementNotFound:
   Unable to find field "inventory_1"