diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..1e575c6 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,31 @@ +name: Check Docs + +on: + push: + branches: [v3.0] + pull_request: null + +jobs: + sphinx: + name: Sphinx reStructuredText validity + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - name: Install sphinx-lint + run: | + pip install --user sphinx-lint + - name: Check Sphinx document sources + run: | + git ls-files --cached -z -- '*.rst' \ + | xargs --null -- python -m sphinxlint --enable all --max-line-length 120 + + typos: + name: Typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Search for misspellings + uses: crate-ci/typos@master diff --git a/community.rst b/community.rst index da79397..32c8917 100644 --- a/community.rst +++ b/community.rst @@ -3,7 +3,8 @@ Community Behat has an amazing community around it. -The Behat community is friendly and welcoming. All questions and comments are valuable, so please come join the discussion! +The Behat community is friendly and welcoming. All questions and comments are +valuable, so please come join the discussion! There are a number of places to connect with community members at all experience levels. diff --git a/cookbooks/creating_a_context_configuration_extension.rst b/cookbooks/creating_a_context_configuration_extension.rst index a5db068..5f28fda 100644 --- a/cookbooks/creating_a_context_configuration_extension.rst +++ b/cookbooks/creating_a_context_configuration_extension.rst @@ -124,7 +124,9 @@ The ``configure`` method is used to define the configuration tree. .. note:: - The ``initialize`` and ``process`` methods are empty in our case but are useful when you need to interact with other extensions or process the container after it has been compiled. + The ``initialize`` and ``process`` methods are empty in our case but are + useful when you need to interact with other extensions or process the + container after it has been compiled. Initializing the Context ------------------------ @@ -132,7 +134,7 @@ Initializing the Context To pass configuration values to our ``HelloWorldContext``, we need to create an initializer. .. code-block:: - + src/ Context/ Initializer/ @@ -180,7 +182,8 @@ The code for ``HelloWorldInitializer.php``: } } -We need to register the initializer definition within the Behat container through the ``HelloWorldExtension``, ensuring it gets loaded: +We need to register the initializer definition within the Behat container +through the ``HelloWorldExtension``, ensuring it gets loaded: .. code-block:: php @@ -211,9 +214,11 @@ We need to register the initializer definition within the Behat container throug Using the extension ------------------- -Now that the extension is ready and will inject values into context, we just need to configure it into a project. +Now that the extension is ready and will inject values into context, we just +need to configure it into a project. -In the ``extensions`` key of a profile (``default`` in our case), we'll add the ``HelloWorldExtension`` key and configure our ``text`` and ``enable`` value. +In the ``extensions`` key of a profile (``default`` in our case), we'll add +the ``HelloWorldExtension`` key and configure our ``text`` and ``enable`` value. Finally, we need to load the ``HelloWorld\Context\HelloWorldContext`` into our suite. @@ -247,7 +252,8 @@ Conclusion ---------- Congratulations! You have just created a simple Behat extension. -This extension demonstrates three of the common steps to building a Behat extension: defining an extension, creating an initializer, and configuring contexts. +This extension demonstrates three of the common steps to building a Behat +extension: defining an extension, creating an initializer, and configuring contexts. Feel free to experiment with this extension and expand its functionality. diff --git a/user_guide/command_line_tool/formatting.rst b/user_guide/command_line_tool/formatting.rst index 61c79e9..51a4385 100644 --- a/user_guide/command_line_tool/formatting.rst +++ b/user_guide/command_line_tool/formatting.rst @@ -62,4 +62,4 @@ respectively: .. code-block:: bash - $ behat --no-colors \ No newline at end of file + $ behat --no-colors diff --git a/user_guide/configuration.rst b/user_guide/configuration.rst index f56d21a..a050d71 100644 --- a/user_guide/configuration.rst +++ b/user_guide/configuration.rst @@ -98,7 +98,8 @@ Or maybe we want to unset the tag filter for a profile: Importing Config ---------------- -The ``imports`` block can be used to merge multiple configuration files in to one loaded config in Behat, using the following syntax: +The ``imports`` block can be used to merge multiple configuration files in to +one loaded config in Behat, using the following syntax: .. code-block:: yaml @@ -107,9 +108,13 @@ The ``imports`` block can be used to merge multiple configuration files in to on - config/base.behat.yml - config/ci.behat.yml -All files from the ``imports`` block will be loaded by Behat and merged, in the listed order, into your ``behat.yml`` config. This is especially useful when you want to tweak configuration slightly between local development and on Continuous Integration environments by using partial configuration files. +All files from the ``imports`` block will be loaded by Behat and merged, in +the listed order, into your ``behat.yml`` config. This is especially useful +when you want to tweak configuration slightly between local development and +on Continuous Integration environments by using partial configuration files. -This allows configuration files listed in the ``imports`` key to override configuration values for previously listed files. +This allows configuration files listed in the ``imports`` key to override +configuration values for previously listed files. Global profile configuration ---------------------------- @@ -121,7 +126,7 @@ You can set some global configuration in your profile configuration: # behat.yml default: testers: # these are the default values - stop_on_failure: false + stop_on_failure: false strict: false Combining the fact that you can override the default profile, you can change the configuration per profile: @@ -139,9 +144,11 @@ Combining the fact that you can override the default profile, you can change the stop_on_failure: false strict: true -This way, with the default profile behat will stop on failure and won't be strict, but will not stop and will be strict if the CI profile is selected. +This way, with the default profile behat will stop on failure and won't be + strict, but will not stop and will be strict if the CI profile is selected. -You can force `--stop-on-failure` and `--strict` via CLI options to override configuration values. +You can force ``--stop-on-failure`` and ``--strict`` via CLI options to override +configuration values. Environment Variable - BEHAT_PARAMS ----------------------------------- @@ -155,23 +162,27 @@ environment variable: You can set any value for any option that is available in a ``behat.yml`` file. Just provide options in *JSON* format. Behat will use those options as defaults. -You can always override them with the settings in the project ``behat.yml`` file (it has higher priority). +You can always override them with the settings in the project ``behat.yml`` +file (it has higher priority). .. tip:: - In order to specify a parameter in an environment variable, the value *must not* exist in your ``behat.yml`` + In order to specify a parameter in an environment variable, the value + *must not* exist in your ``behat.yml`` .. tip:: - NOTE: In Behat 2.x this variable was in *URL* format. It has been changed to use *JSON* format. + NOTE: In Behat 2.x this variable was in *URL* format. It has been changed + to use *JSON* format. Global Filters -------------- -While it is possible to specify filters as part of suite configuration, sometimes you will want to -exclude certain scenarios across the suite, with the option to override the filters at the command line. +While it is possible to specify filters as part of suite configuration, +sometimes you will want to exclude certain scenarios across the suite, +with the option to override the filters at the command line. -This is achieved by specifying the filter in the `gherkin` configuration: +This is achieved by specifying the filter in the ``gherkin`` configuration: .. code-block:: yaml @@ -182,7 +193,7 @@ This is achieved by specifying the filter in the `gherkin` configuration: filters: tags: ~@wip -In this instance, scenarios tagged as `@wip` will be ignored unless the CLI command is run with a custom filter, e.g.: +In this instance, scenarios tagged as ``@wip`` will be ignored unless the CLI command is run with a custom filter, e.g.: .. code-block:: bash @@ -203,7 +214,9 @@ you want to autoload via ``behat.yml``: autoload: '': '%paths.base%/app/features/bootstrap' -If you wish to namespace your features (for example: to be PSR-1 compliant) you will need to add the namespace to the classes and also tell behat where to load them. Here ``contexts`` is an array of classes: +If you wish to namespace your features (for example: to be PSR-1 compliant) +you will need to add the namespace to the classes and also tell behat where +to load them. Here ``contexts`` is an array of classes: .. code-block:: yaml @@ -266,7 +279,7 @@ Extensions can be configured like this: # behat.yml default: - extensions: + extensions: Behat\MinkExtension: base_url: http://www.example.com - selenium2: ~ + selenium2: ~ diff --git a/user_guide/configuration/suites.rst b/user_guide/configuration/suites.rst index fb39c77..c176e87 100644 --- a/user_guide/configuration/suites.rst +++ b/user_guide/configuration/suites.rst @@ -87,7 +87,7 @@ This will cause Behat to: .. note:: ``%paths.base%`` is a special variable in ``behat.yml`` that refers - to the folder in which ``behat.yml`` is stored. When using it, or + to the folder in which ``behat.yml`` is stored. When using it, or any other percent-encased variable, it has to be put in quotes. Path-based suites are an easy way to test highly-modular applications @@ -122,7 +122,7 @@ features with specific tag (or name) in specific contexts: .. note:: - The `@` character is a special and requires the tag to be + The ``@`` character is a special and requires the tag to be put in quotes. This configuration will tell Behat to run features and scenarios diff --git a/user_guide/context.rst b/user_guide/context.rst index 9a916c8..23517e2 100644 --- a/user_guide/context.rst +++ b/user_guide/context.rst @@ -394,4 +394,4 @@ both context classes. In other words, if your Suite uses at least two different Contexts, and those context classes ``use`` the same Trait, this will result in a duplicate - step definition and Behat will complain by throwing a ``Redundant`` exception. \ No newline at end of file + step definition and Behat will complain by throwing a ``Redundant`` exception. diff --git a/user_guide/context/definitions.rst b/user_guide/context/definitions.rst index e54c043..97a2e12 100644 --- a/user_guide/context/definitions.rst +++ b/user_guide/context/definitions.rst @@ -137,7 +137,7 @@ always use good old regular expressions: public function thereAreMonsters($count) {} And if you want to be able to say things in different ways that are not so -easily written as a single regular expression, you can write multiple +easily written as a single regular expression, you can write multiple annotations for the one method: .. code-block:: php @@ -152,9 +152,12 @@ Behat will call the corresponding method if any of the patterns matches. .. note:: - Behat uses the ``preg_match()`` function to match these regular expressions to arguments. Special care is needed to make sure - that there is only one capturing group for each argument. A expression like ``(?P([\w\s]+))`` contains an inner capturing - group (``([\w\s]+)``) and this may make some arguments not match correctly. The right expression to use would be ``(?P[\w\s]+)`` + Behat uses the ``preg_match()`` function to match these regular expressions + to arguments. Special care is needed to make sure that there is only one + capturing group for each argument. A expression like ``(?P([\w\s]+))`` + contains an inner capturing group (``([\w\s]+)``) and this may make some + arguments not match correctly. The right expression to use would be + ``(?P[\w\s]+)`` Definition Snippets ------------------- diff --git a/user_guide/gherkin.rst b/user_guide/gherkin.rst index dc47f91..11589fb 100644 --- a/user_guide/gherkin.rst +++ b/user_guide/gherkin.rst @@ -102,4 +102,4 @@ run: type, which is very important for methodologies like BDD and also gives Behat the ability to have multilanguage features in one suite. -.. _`Business Readable, Domain Specific Language`: http://martinfowler.com/bliki/BusinessReadableDSL.html \ No newline at end of file +.. _`Business Readable, Domain Specific Language`: http://martinfowler.com/bliki/BusinessReadableDSL.html diff --git a/user_guide/initialize.rst b/user_guide/initialize.rst index d96c120..4552c6e 100644 --- a/user_guide/initialize.rst +++ b/user_guide/initialize.rst @@ -46,4 +46,4 @@ Suite Initialisation Suites are a core part of Behat. Any feature of Behat knows about them and can give you a hand with them. For example, if you defined your suites in ``behat.yml`` before running ``--init``, it will actually -create the folders and suites you configured, instead of the default ones. \ No newline at end of file +create the folders and suites you configured, instead of the default ones. diff --git a/user_guide/integrations.rst b/user_guide/integrations.rst index fc28bac..30346f8 100644 --- a/user_guide/integrations.rst +++ b/user_guide/integrations.rst @@ -39,4 +39,4 @@ Drupal. See the documentation of the extension for more info and usage. .. _`Mink`: https://mink.behat.org/ .. _`Mink Extension`: https://github.com/FriendsOfBehat/MinkExtension .. _`Symfony Extension`: https://github.com/FriendsOfBehat/SymfonyExtension -.. _`Drupal Extension`: https://github.com/jhedstrom/drupalextension \ No newline at end of file +.. _`Drupal Extension`: https://github.com/jhedstrom/drupalextension diff --git a/user_guide/organizing.rst b/user_guide/organizing.rst index fb4785d..89ea290 100644 --- a/user_guide/organizing.rst +++ b/user_guide/organizing.rst @@ -30,4 +30,4 @@ with spaces: .. note:: If a tag exists on a ``Feature``, Behat will assign that tag to all - child ``Scenarios`` and ``Scenario Outlines`` too. \ No newline at end of file + child ``Scenarios`` and ``Scenario Outlines`` too.