저는 Capybara (2.1.0 사용)을 처음 사용하기 때문에 새로운 (Rails 4/Ruby 2) 응용 프로그램의 일부 필드를 채울 수 없습니다. 방금 시작 되었기 때문에 앱은 간단합니다.Capybara는 필드를 채우지 않습니다
내 사용자 # new에 대해 유효성 검사가있는 하나의 필드를 채우고 유효 할 때 저장하고 그렇지 않은 경우 실패합니다. 큰. 나는 다른 모델을 가지고 CoiReport # new를 시도하고 작동하지 않는다.
save_and_open_page가 click_button "Create New"보다 먼저 입력 되어도 "Owner is not empty"(validate_presence 유효성 검사기가 있음)로 계속 실패합니다. 필드가 필드이므로 필드가 있으므로 생각했습니다. 그것은,하지만 심지어 그것을 입력 = "텍스트"로 변경했을 때 그것은 여전히 실패합니다. 내가 손으로 할 때도 작동합니다.
그래서이 두 가지 모두 매우 단순한 형태지만, 하나는 효과가 있고 그렇지 않습니다. 나는 그 차이점을 생각할 수 없습니다!
다음은 폼의 :
<%= form_for(@coi_record) do |f| %>
<% if @coi_record.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@coi_record.errors.count, "error") %> prohibited this coi_record from being saved:</h2>
<ul>
<% @coi_record.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :owner_id %><br>
<%= f.text_field :owner_id %>
</div>
<div class="field">
<%= f.label :signer_id %><br>
<%= f.text_field :signer_id %>
</div>
<div class="field">
<%= f.label :signed_at %><br>
<%= f.datetime_select :signed_at %>
</div>
<div class="field">
<%= f.label :is_current %><br>
<%= f.check_box :is_current %>
</div>
<div class="field">
<%= f.label :has_no_conflicts %><br>
<%= f.check_box :has_no_conflicts %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
그리고 여기 테스트입니다 :
require 'spec_helper'
describe 'test2' do
it "should work!" do
visit '/coi_records/new'
page.should have_content('New coi_record')
within '#new_coi_record' do
fill_in 'Owner', :with => '1'
check 'Is current'
check 'Has no conflicts'
click_button 'Create Coi record'
end
# save_and_open_page
page.should have_content('Coi record was successfully created.')
end
end
도와주세요!
이것은 카피 바라 문제와 같은 냄새가 아닙니다. @ci_record를 디버그하고 컨트롤러의'@coi_record.save' 라인 바로 앞에있는 상태를 검사해볼 수 있습니까? – depa
<% = p @coi_record %>
을보기에 추가했습니다. 사양을 실행하면 두 개의 출력이 표시됩니다. 하나는 페이지에 처음 도착한 것이고 두 번째 출력은 저장하지 못하고 편집을 위해 페이지가 다시 표시됩니다. 두 번째 경우에서는 소유자 == 1로해야하며 유효성 검사를 통과해야합니다. # CoiRecord ID : nil, signer_id : nil, signed_at : nil, is_current : nil, has_no_conflicts : nil, created_at : nil, updated_at : nil> #