【问题标题】:How to add the value of another field to an HTTParty field using Ruby如何使用 Ruby 将另一个字段的值添加到 HTTParty 字段
【发布时间】:2019-10-16 18:47:15
【问题描述】:

可以使用这个:将密码生成的伪造内容添加到“passoword_confirmation”。如果是这样,语法是什么,尝试各种方法并失败!。谢谢

"email": Faker::Internet.email, "密码": Faker::number(6), “密码确认”:

@@base_url  = 'https://api-de-tarefas.herokuapp.com/users'
    @@body = 
    {
    "user": {
    "email": Faker::Internet.email,
    "password": Faker::number(6),
    "password_confirmation":      here I want to receive the password generated from Faker.

     }    
}.to_json

【问题讨论】:

标签: ruby cucumber capybara httparty


【解决方案1】:

您可以通过在输入@@body 块之前将密码保存到变量中来保持密码。

@@base_url  = 'https://api-de-tarefas.herokuapp.com/users'
fake_password = Faker::number(6)
@@body = 
{
  "user": {
    "email": Faker::Internet.email,
    "password": fake_password,
    "password_confirmation": fake_password

   }    
}.to_json

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-24
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多