diff --git a/.gherkin-lintignore b/.gherkin-lintignore new file mode 100644 index 00000000..20b8ca6d --- /dev/null +++ b/.gherkin-lintignore @@ -0,0 +1 @@ +features/i18n/*/*.feature diff --git a/.gherkin-lintrc b/.gherkin-lintrc new file mode 100644 index 00000000..50ae29b5 --- /dev/null +++ b/.gherkin-lintrc @@ -0,0 +1,36 @@ +{ + "no-files-without-scenarios" : "on", + "no-unnamed-features": "on", + "no-unnamed-scenarios": "on", + "no-dupe-scenario-names": "on", + "no-dupe-feature-names": "on", + "no-partially-commented-tag-lines": "on", + "indentation": [ + "on", { + "Feature": 0, + "Background": 2, + "Scenario": 2, + "Examples": 4, + "example": 6, + "Step": 4 + } + ], + "no-trailing-spaces": "on", + "new-line-at-eof": ["on", "yes"], + "no-multiple-empty-lines": "on", + "no-empty-file": "on", + "no-scenario-outlines-without-examples": "on", + "name-length": [ + "on", { + "Feature": 100, + "Scenario": 120, + "Step": "off" + } + ], + "no-restricted-tags": ["on", {"tags": ["@watch", "@wip"]}], + "use-and": "on", + "no-duplicate-tags": "on", + "no-superfluous-tags": "on", + "no-homogenous-tags": "off", + "one-space-between-tags": "on" +} diff --git a/.gitignore b/.gitignore index 4d3f649c..49877fd3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ composer.lock vendor /drupal* behat.yml +/package-lock.json /node_modules diff --git a/composer.json b/composer.json index 734f9465..2705f769 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ "parallel-lint src spec features fixtures", "phpcs --standard=./phpcs-ruleset.xml -p", "phpcs --standard=./phpcs-drupal-ruleset.xml -p", + "npm test", "phpspec run -f pretty --no-interaction" ] }, diff --git a/features/api.feature b/features/api.feature index db239b58..6c4c84f4 100644 --- a/features/api.feature +++ b/features/api.feature @@ -1,5 +1,5 @@ @api -Feature: DrupalContext +Feature: DrupalContext general testing In order to prove the Drupal context is working properly As a developer I need to use the step definitions of this context @@ -13,33 +13,19 @@ Feature: DrupalContext Then I should see the text "Member for" @drushTest @d7 - Scenario: Target links within table rows + Scenario: Target links within table rows for Drush and Drupal 7 Given I am logged in as a user with the "administrator" role When I am at "admin/structure/types" And I click "manage fields" in the "Article" row Then I should be on "admin/structure/types/manage/article/fields" And I should see text matching "Add new field" - @d8 - Scenario: Target links within table rows - Given I am logged in as a user with the "administrator" role - When I am at "admin/structure/types" - And I click "Manage fields" in the "Article" row - Then I should be on "admin/structure/types/manage/article/fields" - And I should see text matching "Add field" - @drushTest @d7 - Scenario: Find a heading in a region + Scenario: Find a heading in a region for Drupal 7 Given I am not logged in When I am on the homepage Then I should see the heading "User login" in the "left sidebar" region - @d8 - Scenario: Find a heading in a region - Given I am not logged in - When I am on the homepage - Then I should see the heading "Search" in the "left sidebar" region - @drushTest @d7 @d8 Scenario: Clear cache Given the cache has been cleared @@ -104,7 +90,7 @@ Feature: DrupalContext Then I should see the link "Joe User" @d7 - Scenario: Create users with roles + Scenario: Create users with roles for Drupal 7 Given users: | name | mail | roles | | Joe User | joe@example.com | administrator | @@ -114,17 +100,6 @@ Feature: DrupalContext Then I should see the text "administrator" in the "Joe User" row And I should not see the text "administrator" in the "Jane User" row - @d8 - Scenario: Create users with roles - Given users: - | name | mail | roles | - | Joe User | joe@example.com | administrator | - | Jane User | jane@example.com | | - And I am logged in as a user with the "administrator" role - When I visit "admin/people" - Then I should see the text "Administrator" in the "Joe User" row - And I should not see the text "administrator" in the "Jane User" row - @d7 @d8 Scenario: Login as a user created during this scenario Given users: @@ -140,7 +115,7 @@ Feature: DrupalContext Then I should see the heading "My tag" @d7 - Scenario: Create many terms + Scenario: Create many terms for Drupal 7 Given "tags" terms: | name | | Tag one | @@ -151,7 +126,7 @@ Feature: DrupalContext And I should see "Tag two" @d8 - Scenario: Create many terms + Scenario: Create many terms for Drupal 8 Given "tags" terms: | name | | Tag one | @@ -162,7 +137,7 @@ Feature: DrupalContext And I should see "Tag two" @d7 - Scenario: Create terms using vocabulary title rather than machine name. + Scenario: Create terms using vocabulary title rather than machine name for Drupal 7. Given "Tags" terms: | name | | Tag one | @@ -173,7 +148,7 @@ Feature: DrupalContext And I should see "Tag two" @d8 - Scenario: Create terms using vocabulary title rather than machine name. + Scenario: Create terms using vocabulary title rather than machine name for Drupal 8. Given "Tags" terms: | name | | Tag one | @@ -248,7 +223,7 @@ Feature: DrupalContext Then I should see the link "Joe User" @d7 - Scenario: Term hooks are functioning + Scenario: Term hooks are functioning for Drupal 7 Given "tags" terms: | Label | | Tag one | @@ -259,7 +234,7 @@ Feature: DrupalContext And I should see "Tag two" @d8 - Scenario: Term hooks are functioning + Scenario: Term hooks are functioning for Drupal 8 Given "tags" terms: | Label | | Tag one | diff --git a/features/api_background.feature b/features/api_background.feature index 3d911995..4d232987 100644 --- a/features/api_background.feature +++ b/features/api_background.feature @@ -1,5 +1,5 @@ @d6 @d7 @d8 @api -Feature: DrupalContext +Feature: DrupalContext with background steps Test DrupalContext in combination with Backgrounds Background: @@ -8,12 +8,12 @@ Feature: DrupalContext | Tag one | | Tag two | - Given users: + And users: | name | | User one | | User two | - Given "article" content: + And "article" content: | title | | Node one | | Node two | diff --git a/features/blackbox.feature b/features/blackbox.feature index 62c6b729..a7218419 100644 --- a/features/blackbox.feature +++ b/features/blackbox.feature @@ -68,21 +68,21 @@ Feature: Test DrupalContext And I should see the "div" element with the "class" attribute set to "class3" in the "left header" region Scenario: Error messages - Given I am on "user.html" - When I press "Log in" - Then I should see the error message "Password field is required" - And I should not see the error message "Sorry, unrecognized username or password" - And I should see the following error messages: - | error messages | - | Username or email field is required. | - | Password field is required | - And I should not see the following error messages: - | error messages | - | Sorry, unrecognized username or password | - | Unable to send e-mail. Contact the site administrator if the problem persists | - - @javascript - Scenario: Zombie driver is functional - Given I am on the homepage - When I click "Download & Extend" - Then I should see the link "Distributions" + Given I am on "user.html" + When I press "Log in" + Then I should see the error message "Password field is required" + And I should not see the error message "Sorry, unrecognized username or password" + And I should see the following error messages: + | error messages | + | Username or email field is required. | + | Password field is required | + And I should not see the following error messages: + | error messages | + | Sorry, unrecognized username or password | + | Unable to send e-mail. Contact the site administrator if the problem persists | + + @javascript + Scenario: Zombie driver is functional + Given I am on the homepage + When I click "Download & Extend" + Then I should see the link "Distributions" diff --git a/features/d6.feature b/features/d6.feature index b79e7e1e..5ca7933e 100644 --- a/features/d6.feature +++ b/features/d6.feature @@ -3,27 +3,23 @@ Feature: Environment check Scenario: Frontpage Given I am not logged in - And I am on the homepage + And I am on the homepage Then I should see "User login" Scenario: assertAnonymousUser Given I am an anonymous user - @api Scenario: assertAuthenticatedByRole Given I am logged in as a user with the "authenticated" role - @api Scenario: assertAuthenticatedByRoleWithGivenFields Given I am logged in as a user with the "authenticated" role and I have the following fields: | name | test | - @api Scenario: createNode Given I am viewing a story with the title "test" Then I should see "test" - @api Scenario: createNodes Given article content: | title | author | status | created | @@ -31,12 +27,10 @@ Feature: Environment check When I am viewing a content with the title "My title" Then I should see "My title" - @api Scenario: createTerm Given I am viewing a tags term with the name "example tag" Then I should see "example tag" - @api Scenario: createUsers Given I am logged in as a user with the "administer users" permission And users: @@ -45,9 +39,8 @@ Feature: Environment check | user bar | baz@bar.com | When I visit "admin/user/user" Then I should see "user foo" - And I should see "user bar" + And I should see "user bar" - @api Scenario: create node with terms. Given tags terms: | name | diff --git a/features/d8.feature b/features/d8.feature index 6cefd974..96d94bb5 100644 --- a/features/d8.feature +++ b/features/d8.feature @@ -1,22 +1,22 @@ @d8 @api -Feature: DrupalContext +Feature: DrupalContext for Drupal 8 In order to prove the Drupal context is working properly for Drupal 8 As a developer I need to use the step definitions of this context - Scenario: Create and log in as a user + Scenario: Create and log in as a user for Drupal 8 Given I am logged in as a user with the "authenticated user" role When I click "My account" Then I should see the text "Member for" - Scenario: Target links within table rows + Scenario: Target links within table rows for Drupal 8 Given I am logged in as a user with the "administrator" role When I am at "admin/structure/types" And I click "Manage fields" in the "Article" row Then I should be on "admin/structure/types/manage/article/fields" And I should see the link "Add field" - Scenario: Create users with roles + Scenario: Create users with roles for Drupal 8 Given users: | name | mail | roles | | Joe User | joe@example.com | Administrator | @@ -26,7 +26,7 @@ Feature: DrupalContext Then I should see the text "Administrator" in the "Joe User" row And I should not see the text "administrator" in the "Jane Doe" row - Scenario: Find a heading in a region + Scenario: Find a heading in a region for Drupal 8 Given I am not logged in When I am on the homepage Then I should see the heading "Search" in the "left sidebar" region diff --git a/features/drush.feature b/features/drush.feature index ccc79cff..81aece17 100644 --- a/features/drush.feature +++ b/features/drush.feature @@ -7,15 +7,15 @@ Feature: Drush-specific steps Scenario: drush command with text matching: drush output correct status Given I run drush "st" Then drush output should contain "Drupal version" - Then drush output should contain "Site URI" - Then drush output should match "/.*Site\sURI\s+:.*/" - Then drush output should contain "Database driver" - Then drush output should contain "Successful" - Then drush output should not contain "NonExistantWord" + And drush output should contain "Site URI" + And drush output should match "/.*Site\sURI\s+:.*/" + And drush output should contain "Database driver" + And drush output should contain "Successful" + And drush output should not contain "NonExistantWord" Scenario: drush command with arguments: re-enable toolbar Given I run drush "en" "toolbar -y" - And I run drush "en" "toolbar -y" + And I run drush "en" "toolbar -y" Then drush output should contain "toolbar is already enabled." Scenario: Create and view a node with fields using the Drush driver diff --git a/features/field_handlers.feature b/features/field_handlers.feature index da8448cf..17160180 100644 --- a/features/field_handlers.feature +++ b/features/field_handlers.feature @@ -134,7 +134,7 @@ Feature: FieldHandlers But I should not see the link "Tag three" And I should see "Page one" And I should see "Page two" - But I should not see "Page three" + And I should not see "Page three" And I should see "Belgium" And I should see "Brussel" And I should see "1000" diff --git a/features/mail.feature b/features/mail.feature index 4890ee30..53c1f24b 100644 --- a/features/mail.feature +++ b/features/mail.feature @@ -49,7 +49,6 @@ Feature: MailContext | subject | | test 1 | - Scenario: No mail is sent Then no mail has been sent diff --git a/features/messages.feature b/features/messages.feature index 802bbd7d..7ed6aeb1 100644 --- a/features/messages.feature +++ b/features/messages.feature @@ -7,7 +7,7 @@ Feature: Ensure that messages are working properly on local installs Given I am on "/user/login" When I fill in "a fake user" for "Username" And I fill in "a fake password" for "Password" - When I press "Log in" + And I press "Log in" Then I should see the error message "Unrecognized username or password" @javascript @@ -15,5 +15,5 @@ Feature: Ensure that messages are working properly on local installs Given I am on "/user/login" When I fill in "a fake user" for "Username" And I fill in "a fake password" for "Password" - When I press "Log in" + And I press "Log in" Then I should see the error message "Unrecognized username or password" diff --git a/features/subcontexts/find.feature b/features/subcontexts/find.feature index 91af75f0..034ae522 100644 --- a/features/subcontexts/find.feature +++ b/features/subcontexts/find.feature @@ -54,15 +54,15 @@ Feature: Ability to find Drupal sub-contexts """ Scenario: Step-definitions in sub-contexts are available - When I run "behat --no-colors -dl" - Then the output should contain: + When I run "behat --no-colors -dl" + Then the output should contain: """ Then /^I should have a subcontext definition$/ """ - Scenario: Subcontext can be instantiated - When I run "behat --no-colors" - Then the output should contain: - """ - TODO: write pending definition - """ + Scenario: Subcontext can be instantiated + When I run "behat --no-colors" + Then the output should contain: + """ + TODO: write pending definition + """ diff --git a/package.json b/package.json index 20df6400..6fe1995c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,10 @@ { "devDependencies": { + "gherkin-lint": "^2.12.0", "zombie": "^2.5" + }, + "scripts": { + "gherkin-lint": "gherkin-lint features", + "test": "npm run gherkin-lint" } }