Ruby on rails 注册用户,然后通过系统测试访问帐户页面?
如果我理解正确的话,在下面这样的表单中创建用户不会在数据库中创建记录 我想创建一个系统测试来遵循以下步骤:Ruby on rails 注册用户,然后通过系统测试访问帐户页面?,ruby-on-rails,testing,capybara,minitest,system-testing,Ruby On Rails,Testing,Capybara,Minitest,System Testing,如果我理解正确的话,在下面这样的表单中创建用户不会在数据库中创建记录 我想创建一个系统测试来遵循以下步骤: 1在表格中注册 2访问帐户页面 三。更新帐户信息 什么技术可以实现上述场景 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'
1在表格中注册
2访问帐户页面
三。更新帐户信息 什么技术可以实现上述场景
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
用户记录是否实际提交到数据库取决于您是否正在使用事务测试。如果您使用的是事务性测试,那么记录实际上不会被提交,但这并不重要,因为(如果配置正确)测试和应用程序中的所有内容都应该访问相同的预提交事务,因此可以查看记录。做你想做的事,你会做的
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
谢谢!这让人大开眼界。但不幸的是,我的根本问题仍然存在。我,如果你有时间看的话。