0

如果我理解正确,以如下形式创建用户不会在数据库中创建记录。

我想创建一个系统测试以遵循以下步骤:
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: 'eve@example.com'
    fill_in 'password', with: 'Something'
    find('button').click
end
4

1 回答 1

1

用户记录是否实际提交到数据库取决于您是否使用事务测试。如果您正在使用事务测试,那么记录实际上不会被提交,但这无关紧要,因为(如果配置正确)您的测试和应用程序中的所有内容都应该访问相同的预提交事务,因此会看到记录。做你要求做的事

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: 'eve@example.com'
  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
于 2017-12-02T00:19:54.970 回答