(. do role credentials 'member' :username 'testmember :password 'Passw0rd', 'admin' :username 'testadmin :password 'secret123' unless clude?(role) throw "Unknown role: #role" end visit home_page fill_in :username, :with credentialsrole:username fill_in :password, :with credentialsrole:password click_button 'Sign in' end Running Scenarios and Integrating with Other Tools Automated tests are only useful if you can run them. After we add a few scenarios, the feature for the Medical Provider Search might look like: Feature: Medical Provider Search In order to avoid paying out-of-network fees for medical care, insurance policy holders (aka members) want to find medical providers covered by their insurance for particular specialties, locations, etc.
When it finds a match, it will execute that step definition. When it cant find a match, it will suggest code you could use to create a matching step definition. Passing steps are colored green, failing steps red, and undefined and pending steps yellow.
Capture groups in the regular expression become arguments to the step definition. For example, if we wanted to extend the first step definition to support multiple roles, we might modify it to look like the following: Given /I'm logged in as an? At this time, the focus was at the class and method level. Later, BDD grew to encompass requirements and analysis, and the emphasis moved to describing behavior at the system level.