私はcucumber/capybara/site_prismのさまざまなログイン資格情報で多くのテストを行っていますが、これはかなり面倒です。私は可能な限り統一したい。このソリューションは、https://blog.jayway.com/2012/04/03/cucumber-data-driven-testing-tips/キュウリ/カピバラを使ったハッシュデータの保存と抽出
素敵なように見えた。しかし、私は、私はハッシュがどのように処理すべきか誤解し、どうやらステップ定義
Your block takes 1 argument, but the Regexp matched 2 arguments.
の非常に最初の行のためにこれに実行例を以下のとき。誰かが助けてくれますか?少ないテストデータと私のコードが一致している2番目のパラメータがdata_tableあるので、あなたはそのエラーを取得している キュウリの下
Given I login as "ad" with the following data:
|role|usern |userpass |
|ad |adcccount |adpassword |
|ml |mlaccount |mlpassword |
ステップ定義
Given /^I login as "(ad|ml)" with the following data:/ do |user|
temp_hash = {}
if (user == "ad")
temp_hash = $ad
elsif (user == "ml")
temp_hash = $ml
end
usern = temp_hash["usern"]
userpass = temp_hash["userpass"]
@app = App.new
@app.login.load
@app.login.username.set usern
@app.login.password.set userpass
@app.login.btn_login.click
end