簡體   English   中英

黃瓜步驟定義為“鑒於我已登錄”

[英]Cucumber step definition for “Given that I'm logged in”

我有一個黃瓜步驟:鑒於我已登錄

我不明白我應該如何將其作為步驟定義來實現。

有人能指出我正確的方向,教程,博客等。

這是我怎么做的。

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

我這樣做的原因是,我運行整個堆棧並按照普通用戶的方式設置環境......

嗨您可以將此步驟分為三個較小的步驟

1. visit login page
2. fill_in login, username
3. press login button

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM