Rspec 正则表达式问题。不确定如何定义场景中(Then)的步骤定义

Rspec 正则表达式问题。不确定如何定义场景中(Then)的步骤定义,rspec,cucumber,watir-webdriver,Rspec,Cucumber,Watir Webdriver,场景大纲:验证完整的广告详细信息 鉴于我在xxxxx分类主页上 我已在搜索字段中输入并单击搜索 当我单击完整详细信息时 那我该看看了< 广告ID>< 标题>< 说明>< CountryName>< 价格> < 缩略图图像>< PartExchange>< 电话>< AltPhone>< 位置>正确且成功地显示 Examples: |AdvertId|Headline|Description|CountryName|Price|ThumbnailImage|PartExchange

场景大纲:验证完整的广告详细信息
鉴于我在xxxxx分类主页上
我已在搜索字段中输入并单击搜索
当我单击完整详细信息时
那我该看看了< 广告ID>< 标题>< 说明>< CountryName>< 价格> < 缩略图图像>< PartExchange>< 电话>< AltPhone>< 位置>正确且成功地显示

    Examples:
    |AdvertId|Headline|Description|CountryName|Price|ThumbnailImage|PartExchange|Phone|AltPhone|Location|
    |219|V12 Vantage Coupe|Powerfold mirrors,Alcantara steering wheel,HID projector headlamps,Electronic brakeforce distribution (EBD),LED rear lamps,Emergency brake assist (EBA),Aston Martin 160 W audio system,Dynamic stability control with Track mode (DSC),Electrically adjustable front seats,Trip computer,Tyre pressure monitoring,Bluetooth telephone preparation,Auto dimming interior rear view mirror,Memory seats and exterior mirrors,Ventilated, carbon ceramic disc brakes with ABS,Aluminium, magnesium alloy, composite and steel body,Side airbags (sports seats only),iPod integration and MP3 connectivity,Carbon fibre door pulls,Rear parking sensors,Hard Disk Drive (HDD) Satellite navigation system,Cruise control,Alarm and immobiliser,Boot-mounted umbrella,Dual stage driver and passenger front airbags|Costa Rica|99000|http://img.pistonheads.com.s3-eu-west-1.amazonaws.com/Thumbnail/aston_martin/v12_vantage/aston_martin-v12_vantage-1012-1.jpg||08444119220||Costa Rica|
    |221|V8 Vantage Coupe 4.7|Side Airbags,Dynamic stability control (DSC),Ventilated, grooved disc brakes with ABS,Aston Martin 160 W audio system, Alarm and immobiliser,Emergency brake assist (EBA),Electronic brakeforce distribution (EBD),Rear parking sensors,6 CD autochanger,Electrically adjustable front seats,LED Rear Lamps,Dual stage driver and passenger front airbags,Tyre pressure monitoring,Trip computer,Full leather interior|Denmark|52906|http://img.pistonheads.com.s3-eu-west-1.amazonaws.com/Thumbnail/aston_martin/v8_vantage/aston_martin-v8_vantage-966-1.jpg||08444119218||Denmark|     
我需要帮助以适当的正则表达式定义步骤定义。在这个场景中,我只展示了两个示例。有没有一种方法可以只编写一行代码和步骤定义,这将适用于任意数量的行示例


对于这种情况的任何答案都将不胜感激。

为了让正则表达式能够区分一个值的结束位置和另一个值的开始位置,您应该在每个值周围添加引号。因此,该步骤将被写为:

Then I should see "<AdvertId>" "<Headline>" "<Description>" "<CountryName>" "<Price>" "<ThumbnailImage>" "<PartExchange>" "<Phone>" "<AltPhone>" "<Location>" displaying correctly and successfully
请注意,有多少示例并不重要。唯一重要的是你的例子的内容。除非在其中一个值中加入引号,否则上述方法应该有效

另一种方法是单独填写每张支票:

Then I should see the advert id "<AdvertID>" displaying correctly and successfully
Then I should see the headline "<Headline>" displaying correctly and successfully
etc

单独编写每一个可以更容易地找出失败的原因,也可以更容易地编写正则表达式。但是,如果检查不是独立的,那么一步可能是最好的选择。

谢谢Justin。明天早上我要试一试。我会带着一些反馈回来。我认为我试图将(\d+)(\w+)(.+)正则表达式添加到我的step定义中,但这些正则表达式根本不起作用,这使问题变得过于复杂。谢谢Justin,它非常有效。我用了你的第二个例子。真棒
Then I should see the advert id "<AdvertID>" displaying correctly and successfully
Then I should see the headline "<Headline>" displaying correctly and successfully
etc
Then /I should see the advert id "(.*)" displaying correctly and successfully/
Then /I should see the headline "(.*)" displaying correctly and successfully/
etc