[英]How do I make a word optional in a Cucumber step definition?
I have a step definition, below, that does what I want it to do ie it checks the url of the page against the 'page' element of 'PAGES' hash. 我在下面有一个步骤定义,它做了我想要它做的事情,即它检查页面的URL与'PAGES'哈希的'page'元素。
Then(/^I should( still)? be at the "(.*)" page$/) do |still, page|
BROWSER.url.should == PAGES[page]
end
The step definition is used for both 步骤定义用于两者
However, I don't need "still" to be passed into the block. 但是,我不需要“仍然”传递到块中。 I just need it to be optional for matching to the step but not passed into the block.
我只需要它是可选的匹配步骤但不会传递到块中。 How can I do that?
我怎样才能做到这一点?
Thanks. 谢谢。
You want to mark the "still" group as non-capturing. 您希望将“静止”组标记为非捕获。 This is done by starting the group with
?:
. 这是通过使用
?:
启动组来完成的。
Then(/^I should(?: still)? be at the "(.*)" page$/) do |page|
BROWSER.url.should == PAGES[page]
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.