저는 오이를 처음 접했고이 통합 테스트가 실패한 이유를 완전히 놓쳤습니다.오이 + Webrat가 양식을 제출하지 않습니까?
Scenario: User changes profile
Given I have an account
When I change my profile
Then my profile should be saved
Scenario: User changes login
Given I have an account
When I change my login information
Then my account should be changed
그리고이 단계의 정의 : 나는 다음과 같은 시나리오가
Given /^I have an account$/ do
@user = Factory.create(:user)
visit login_path
fill_in "Email", :with => @user.email
fill_in "Password", :with => 'secret'
click_button "Sign in"
end
When /^I change my profile$/ do
visit edit_user_profile_path(@user)
fill_in "First name", :with => "John"
fill_in "Last name", :with => "Doe"
click_button "Update Profile"
end
Then /^my profile should be saved$/ do
@user.profile.first_name.should == "John"
@user.profile.last_name.should == "Doe"
end
When /^I change my login information$/ do
visit edit_user_path(@user)
fill_in "Email", :with => "[email protected]"
click_button "Update Login Information"
end
Then /^my account should be changed$/ do
@user.email.should == "[email protected]"
end
을 그리고 나는이 메시지와 함께 두 시나리오 모두에서 "다음"조건 실패 :
# Scenario 1
expected: "John"
got: "Test1" (using ==) (RSpec::Expectations::ExpectationNotMetError)
# Scenario 1
expected: "[email protected]"
got: "[email protected]" (using ==) (RSpec::Expectations::ExpectationNotMetError)
그래서,에 두 경우 모두 사용자 로그인 또는 프로파일을 업데이트하기 위해 양식을 제출 한 후에 공장 정보가 여전히 존재합니다. 그러나 실제 브라우저에서 테스트하면 완벽하게 작동합니다. 그래서, 왜이 시험은 실패합니까?
도움 주셔서 감사합니다.
@user를 사용하는 대신 로그인 한 현재 사용자를 얻는 기능이 있습니까? –
current_user 메서드가 있지만 테스트에서 액세스 할 수 있습니까? 양식을 업데이트하거나 결과를 확인하기 위해 @user 대신에 사용 하시겠습니까? 어쨌든 나는 그것이 어떻게 중요 할지를 보지 못한다. 폼은 분명히 정확한 사용자를 잡아 내고 있고 페이지는 webrat에서 올바르게 로딩되고있다. (내가 무엇을 채우거나 클릭하는지에 대한 에러를 발생시키지 않기 때문에) 컨트롤러는 현재 사용자가 편집 중이 아닌 한 허용하지 않습니다. – Andrew