Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow keywords starting with a variable in bdd style #5096

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JFoederer
Copy link
Contributor

This is a fix for issue #4577.

From Specification by Example's best practices action steps are best written in third person form where the actor is named that performs the action. Oftentimes you want the actor to be a variable, because the actions of the different actors have different consequences.

For example:

Given Alvin Admin is logged in on the portal
and Betty Buyer is logged in on the portal
then Alvin Admin sees Betty Buyer in the online users list
but Betty Buyer cannot see Alvin Admin in the online users list

Before this fix, implementing a keyword like ${user} is logged in on the portal would, in the given step, yield the faulty effect that ${user} gets the value "Given Alvin Admin".

@JFoederer
Copy link
Contributor Author

To address any worries on compatibility. The only time you would notice a change, is when you have a keyword of which the first word is an argument and the data entered for that argument starts with one of the reserved bdd prefixes (given, when, then, etc.), followed by a space and another word. This is a rather unique situation.

For example:
When using the keyword “${beverage} should be served at ${temp}°C” in a non-bdd style context as “But light should be served at 4°C”, the word But would be matched as bdd prefix, but it will only be accepted as valid prefix, because “light should be served at 4°C” also still matches the keyword. You need the double worded ‘But light’ argument to still match the leading variable. This is an opposite example from the one mentioned in the PR description.

The available workarounds for when you do run into this are:
• Making the keyword more specific: The beverage But light should be served at 4°C
• Making the data explicit by adding quotes: ‘${beverage}’ should be served at ${temp}°C

These are the same workarounds that one had to revert to in the old situation. Comparing them, the chance of the new situation occurring is way smaller (more unique) than the chance of the previous situation occurring, with identical penalty cost.

The new implementation still matches the documentation text. No updates needed there in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant