지금 테스트 중이지만 Webrat에서 올바른 필드에 있는지 확인했지만 fill_in
을 사용하여 양식 필드를 찾을 수 없습니다. Webrat은 필드 이름이나 신분증으로 작동합니까? 나는 Ruby 심볼과 폼 이름을 사용하여 필드에 접근하려고 시도했지만, 두 경우 모두 작동하지 않는다. 구현시 잘못된 내용이 있습니까?레일 3 통합 테스트 - webrat fill_in을 사용하여 필드를 찾을 수 없음
오류 메시지 :
5) Forwarding should forward the user to the requested page after signin
Failure/Error: integration_sign_in(user)
Could not find field: :email
테스트 코드 :
it "should forward the user to the requested page after signin" do
user = Factory(:user)
visit edit_user_path(user)
# The test automatically follows the redirect to the signin page
puts current_url
integration_sign_in(user)
# The test follows the redirect again, this time to users/edit
response.should render_template('users/edit')
end
integration_sign_in
이 spec_helper.rb
def integration_sign_in(user)
fill_in :email, :with => user.email
fill_in :password, :with => user.password
click_button
end
에서 양식 필드의 HTML입니다 :
<form action='/sessions' class='mtm' id='sign-in-form' method='post'>
<input name='authenticity_token' type='hidden' value='iIIqT6bUwiJkpqpgxm5sjAj3egrNcEgeXPsYmbKQ02U='>
<div class='landingSignInForm'>
<label class='mas signin-label' for='email'>E-mail:</label>
<input class="mls ras" id="email" name="email" placeholder="e-mail address" type="text" />
<label class='mas signin-label' for='password'>Password:</label>
<input class="mls ras" id="password" name="password" placeholder="password" type="password" />
<input checked='checked' class='mls mtm' name='remember' type='checkbox' value='permanent'>
<span class='remember-me-label'>Keep me signed in</span>
<input class='mls mvm ram medium silver button' name='submit' type='submit' value='Sign in'>
<a class='forgot-password' href='#'>Forget your password?</a>
</div>
</form>
응답 해 주셔서 감사합니다. 불행히도 위의 작업 (기호, 이름, ID 등)이 없습니다. 나는 거의 Webrat을 포기하고 Capybara를 설치하여 Webrat 문제인지 확인하려고합니다. – iwasrobbed
더 이상 도움이되지 않아서 미안 해요. 행운을 빕니다! –
걱정하지 마시고 다시 한번 감사드립니다! – iwasrobbed