私が正しく理解していれば、以下のような形式でユーザーを作成しても、データベースにレコードは作成されません。
次の手順に従うシステムテストを作成したい:
1。フォームにサインアップする
2.アカウントページにアクセスする
3.アカウント情報を更新する
上記のシナリオを達成するには、どのような手法が必要ですか?
within 'form#t-signup-form' do
fill_in 'first_name', with: 'Eve'
fill_in 'last_name', with: 'Farmer'
fill_in 'email', with: '[email protected]'
fill_in 'password', with: 'Something'
find('button').click
end
ユーザーレコードが実際にデータベースにコミットされているかどうかは、トランザクションテストを使用しているかどうかによって異なります。トランザクションテストを使用している場合、レコードが実際にコミットされることはありませんが、(正しく構成されている場合)テストとアプリのすべてが同じプリコミットトランザクションにアクセスする必要があるため、レコードが表示されるため、問題にはなりません。あなたが求めていることをするためにあなたはただするでしょう
visit signup_path #whatever is the correct route to the page with the signup form
within '#t-signup-form' do
fill_in 'first_name', with: 'Eve'
fill_in 'last_name', with: 'Farmer'
fill_in 'email', with: '[email protected]'
fill_in 'password', with: 'Something'
find('button').click
end
assert_content('You are signed up!') # assert for visible change in page that indicates signup has succeeded
visit account_path # route to whatever page you want to go to
... # do whatever actions are required to update the account
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加