I have a step definition, below, that does what I want it to do i.e. it checks the url of the page against the 'page' element of 'PAGES' hash.
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 can have all of your step definitions in one file, or in multiple files. When you start with your project, all your step definitions will probably be in one file. As your project grows, you should split your step definitions into meaningful groups in different files.
Add a Step Definition file 1) Create a new Class file in the 'stepDefinition' package and name it as 'Test_Steps', by right click on the Package and select New > Class. Do not check the option for 'public static void main' and click on Finish button. Take a look at the message in the console window.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With