capybara定义可选参数

时间:2016-12-22 16:27:20

标签: capybara

    <div class="bl">
    <div class="element">
    //your content
    </div>
`</div>`

css
.bl{

    display:inline-block;
     align-items: center;
      justify-content: center;
      height: 400px;
      width: 100%;

}
.element{

    vertical-align:top/middle;


    width:40px;

}

我想用额外的参数

创建相同的定义

为Admin用户提供电子邮件和角色以及删除表

尝试编写此灯具

 Given   Admin user with email and role:

所以如果不存在parametar,默认情况下会为false,但如果我们在定义drop table中,则应该是drop_tables =&gt; true

Given(/^Admin user with email and role(?: and drop table (.*)):$/) do |table, drop|
  add_location :drop_tables => drop || false
  table.hashes.each_with_index do |value, key|
    value[:"Postal Code"] ||= nil
    add_admin_user :role_name => value[:"Role"], :admin_email => value[:"Email"]
  end
  clear_memcache
end

1 个答案:

答案 0 :(得分:0)

我认为你要求的是

Given(/^Admin user with email and role( and drop table)?:$/) do |drop,table|
  add_location :drop_tables => !!drop
  table.hashes.each_with_index do |value, key|
    value[:"Postal Code"] ||= nil
    add_admin_user :role_name => value[:"Role"], :admin_email => value[:"Email"]
  end
  clear_memcache
end

如果&#34;那将设置drop_tables: true和放桌&#34;使用了文字和&#39; drop_table:false&#39;如果它不是