my step definition
Transform /^user "([^"]*)"$/ do | email |
Person.find_by_email(email)
end
Given /^login as (user "([^"]*)")$/ do | user |
login_as email
end
my feature
login as user "ca@example.org"
I am getting this error
And user "ca@example.org" has security role "contact" # features/step_definitions/security_role_steps.rb:14
And login as user "ca@example.org" # features/step_definitions/security_role_steps.rb:10
Your block takes 1 argument, but the Regexp matched 2 arguments. (Cucumber::ArityMismatchError)
features/step_definitions/security_role_steps.rb:10:in `/^login as (user "([^"]*)")$/'
./vendor/plugins/shway_skeletons/lib/shway_skeletons.rb:94:in `send':in `/^login as (user "([^"]*)")$/'
features/manage_security_roles.feature:14:in `And login as user "ca@example.org"'
I am unable to figure out can anybody explain what was wrong with my cucumber transform.
This is because the parentheses around ( user "([^"]*)" ) are capturing a group, then the actual email is capturing another one. to prevent that, use a non-capturing group, or don't group at all.
or