Skip to content

Instantly share code, notes, and snippets.

@mvcds
Last active August 16, 2021 20:45
Show Gist options
  • Save mvcds/1f2d15b714cdc5a20a3ddecf1b3c80c7 to your computer and use it in GitHub Desktop.
Save mvcds/1f2d15b714cdc5a20a3ddecf1b3c80c7 to your computer and use it in GitHub Desktop.
Testing data or rules 6
Feature: Configure ages for country
Given A user from BR
When getting configuration for drive
Then the age should be 18
Given A user from SA
When getting configuration for alcohol
Then the age does not influence if it is allowed
Given A user from US
When getting configuration for drive
Then the age should be 16
//not accurated for cucumber-syntax
//i'm worrying more about the idea behind it
export class CountryConfigSteps {
private country: Country;
private result: number;
@given(/A user from "country"/)
public setCountry(country: string) {
this.country = county as Country;
}
@when(/getting configuration for "kind"/)
public getConfiguration(kind: string) {
this.result = getCountryConfiguration(this.country)[kind];
}
@then(/the age should be \$(\d*)/)
public assertByAge(age: number) {
assert.equal(this.result, age);
}
// the text helps business
// plus i don't think cucumber allows "Infinity" to be used like that
@then(/the age does not influence if it is allowed/)
public assertInfinity() {
this.assertByAge(Infinity)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment