I have the following step:
Then I should see an error message
with identical definition:
Then /^I should see an error message$/ do
page.should have_selector('#flash_alert', text: 'Invalid')
end
in two different features: admin_sign_in.feature and user_login.feature.
Where should I place the definition properly?
Make a new file.
Call it something like
flash_message_steps.rborerror_steps.rbor anything else you like. I would suggest something generic though, calling itadmin_steps.rboruser_steps.rbdoesn’t really make sense. All the files in thestep_definitionsfolder are auto-loaded. Just be sure to define it once only as duplicate definitions for the same step will raise an ambiguity error.I would also recommend making your step more generic, something like:
You can then use the same definition to test multiple errors: