Skip to content

Add support for XDG base directory configuration file

gitlab-qa-bot requested to merge github/fork/Mange/xdg-config-home into master

Created by: Mange

This is an XDG Base Directory Specification-compatible alternative to ~/.rspec.

~/.rspec has higher precedence in order to reduce risk in cases where users have a file like this dormant. It is unlikely, but this way the risk is lower.

If $XDG_CONFIG_HOME is not set, it will fall back to ~/.config, per the specification.

Name of the file

I chose the name rspec/options over, say rspec/config, because:

  • it's referred to as an "options file" in some parts of the documentation
  • it leaves space for the possibility of having a config file that is not based on CLI options (Ruby DSL, YAML, etc.)

It is trivial to change before merging, of course. I think you get to pick a name, so this is just a suggestion.

Other changes

The "isolated home" example tag has been extended with a create_fixture_file helper that also expands the filename and takes care to create the directory where the file resides in, if it does not already exist. Other file creations have been migrated to this method for consistency.

The method is only available when an example is tagged with :isolated_home => true, for safety.

In case the developer running these tests have a custom $XDG_CONFIG_HOME set, it is cleared out when using an isolated home so their real files are not touched.

References

Merge request reports