gpt4 book ai didi

ruby-on-rails - "Given that I' m登录的 cucumber 步骤定义"

转载 作者:数据小太阳 更新时间:2023-10-29 07:03:21 25 4
gpt4 key购买 nike

我有一个 cucumber 步骤:鉴于我已登录

我不明白我应该如何将它作为一个步骤定义来实现。

谁能指出我正确的方向、教程、博客等。

最佳答案

这是我的做法。

Given /^I have one\s+user "([^\"]*)" with email "([^\"]*)" and password "([^\"]*)"$/ do |username,email, password|
@user = User.new(:email => email,
:username=>username,
:password => password,
:password_confirmation => password)
@user.save!
end

Given /^I am an authenticated user$/ do
name = 'exmample'
email = 'example@example.com'
password = 'secret!'

Given %{I have one user "#{name}" with email "#{email}" and password "#{password}"}
And %{I go to the user login page}
And %{I fill in "user_username" with "#{name}"}
And %{I fill in "user_password" with "#{password}"}
And %{I press "Sign in"}
end

我这样做的原因是我遍历整个堆栈并按照普通用户的方式设置环境......

关于ruby-on-rails - "Given that I' m登录的 cucumber 步骤定义",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3496500/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com