I think the only way you can infer that information is by checking the values of the parameters. If the value is nil, nothing was assigned to it (ie that part of the step definition was not used).
For example, if you want behaviour depending on if the email address part was used:
When /^I check the favorite color count(?: for email address (.*))?$/ do |email|
if email.nil?
# Then the "for email address" part was *not* used
else
# Then the "for email address" part was used
end
email ||= "default@domain.com"
puts 'using ' + email
end
Note that this is basically what the line email ||= "default@domain.com"
is doing. The ||=
basically means assign this value if one does not already exist. It would be the same as doing:
When /^I check the favorite color count(?: for email address (.*))?$/ do |email|
if email.nil?
# Then the "for email address" part was *not* used
email = "default@domain.com"
else
# Then the "for email address" part was used
# email already has a value so leave it be
end
puts 'using ' + email
end