-
Notifications
You must be signed in to change notification settings - Fork 118
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
Invalid example in ReusingStepDefinitions.md #65
Comments
I also have a problem with the example ReusingStepDefinitions.md.
|
Same as @boboz2 ! |
Yes, that example is quite flawed. What we need is an easy way to share state between files, as suggested in #61. |
The state cannot really be "shared" because it belongs to the scenario but what about making the shared functions depending only on parameter and not on global states? It is a better coding style anyway ... // shared-steps.js
export const givenIHaveXDollarsInMyBankAccount = (given, account) => {
given(/I have \$(\d+) in my bank account/, balance => {
account.deposit(balance);
});
};
// example.steps.js
givenIHaveXDollarsInMyBankAccount(given, myAccount); What do you think? |
The documentation needs to be updated then. This is real better. I use a class to shared my steps and states instead of functions. |
I can prepare a PR if you would like but it could take a few days. Should I or are you already working on it? |
I can’t work on it right now. I think you should do it 😉 |
@bencompton @Kiyozz the PR should be made for the master or for 2.0.12 ? |
I merge it to default (master), it is an inoffensiv merge anyway. |
Fixed in #76 |
Please take look at ReusingStepDefinitions.md and notice that in the suggested example (second large code block) there is a variable
myAccount
. However this variable does not exist at this point in time. It seems this shared-steps was created as a result of hasty refactoring, and I see no way to link myAccount in the .steps file to the shared-steps.My suggestion would be create a class in shared-steps which can return steps when new'd.
The text was updated successfully, but these errors were encountered: