私はキュウリを初めて勉強しています。なぜこの統合テストが失敗したのか、全く分かりません。キュウリ+ 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