PageObject / Cucumber字符串输入不正确

时间:2015-01-16 19:39:40

标签: ruby cucumber page-object-gem

在我的场景大纲中,我有以下

Examples:
    | user   | password | from            | to            | amount | date      | message           |
    | joel10 | lolpw12  | bankA           | bankB         | $100   | 1/30/2015 | Transfer Success. |

在我的步骤定义中,我有以下

And(/^the user inputs fields (.*), (.*), (.*)$/) do |from, to, amount|
  on(TransferPage).from = /#{from}/
  on(TransferPage).to = /#{to}/
  on(TransferPage).amount = /#{amount}/
  on(TransferPage).date = /#{date}/
end

FROM,TO和AMOUNT都从表中正确显示但是当它输入日期时,它出来了(?-mix:1/30/2015)

为什么会发生这种情况,我该如何解决?

1 个答案:

答案 0 :(得分:0)

执行/#{date}/时,您将获取解析步骤定义返回的值,然后将其转换为正则表达式:

/#{date}/.class
#=> Regexp

您可能希望将值保留为原始的String格式:

on(TransferPage).date = date