Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic feature for gherkin rule/example support
- Loading branch information
1 parent
abfb219
commit 42f244d
Showing
1 changed file
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
Feature: Rule keyword | ||
|
||
Scenario: Rule with multiple examples, passing | ||
Given a file named "features/highlander.feature" with: | ||
""" | ||
Feature: Highlander | ||
Rule: There can be only One | ||
Example: Only One -- More than one alive | ||
Given there are 3 ninjas | ||
And there are more than one ninja alive | ||
When 2 ninjas meet, they will fight | ||
Then one ninja dies | ||
And there is one ninja less alive | ||
Example: Only One -- One alive | ||
Given there is only 1 ninja alive | ||
Then they will live forever | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
import {Given, When, Then} from 'cucumber' | ||
import assert from 'assert' | ||
Given('there are {int} ninjas', function(count) { | ||
this.total = count | ||
}) | ||
Given('there is only 1 ninja alive', function() { | ||
this.living = 1 | ||
}) | ||
Given('there are more than one ninja alive', function() { | ||
this.living = 2 | ||
}) | ||
When('2 ninjas meet, they will fight', function() { | ||
this.deaths = 1 | ||
this.living = 1 | ||
}) | ||
Then('one ninja dies', function() { | ||
assert.equal(1, this.deaths) | ||
}) | ||
Then('there is one ninja less alive', function() { | ||
assert.equal(1, this.living) | ||
}) | ||
Then('they will live forever', function() { | ||
}) | ||
""" | ||
When I run cucumber-js | ||
Then it passes | ||
|
||
Scenario: Rule with multiple examples, failing | ||
Given a file named "features/highlander.feature" with: | ||
""" | ||
Feature: Highlander | ||
Rule: There can be only One | ||
Example: Only One -- More than one alive | ||
Given there are 3 ninjas | ||
And there are more than one ninja alive | ||
When 2 ninjas meet, they will fight | ||
Then one ninja dies | ||
And there is one ninja less alive | ||
Example: Only One -- One alive | ||
Given there is only 1 ninja alive | ||
Then they will live forever | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
import {Given, When, Then} from 'cucumber' | ||
import assert from 'assert' | ||
Given('there are {int} ninjas', function(count) { | ||
this.total = count | ||
}) | ||
Given('there is only 1 ninja alive', function() { | ||
this.living = 1 | ||
}) | ||
Given('there are more than one ninja alive', function() { | ||
this.living = 2 | ||
}) | ||
When('2 ninjas meet, they will fight', function() { | ||
// broken implementation... | ||
}) | ||
Then('one ninja dies', function() { | ||
assert.equal(1, this.deaths) | ||
}) | ||
Then('there is one ninja less alive', function() { | ||
assert.equal(1, this.living) | ||
}) | ||
Then('they will live forever', function() { | ||
}) | ||
""" | ||
When I run cucumber-js | ||
Then it fails |