Skip to content

Migration Guide to Version 0.28.0

Koichi Nakashima edited this page Jan 3, 2021 · 3 revisions

ShellSpec CLI changes

.shellspec is now mandatory

Although the document had previously stated that it was required, no check had actually been done. This file is now required to detect the project root directory.

You will need to run it from the project directory

Up until now, it was possible to run specfile from anywhere. However, it was not working properly because the working directory was the current directory.

Since version 0.28.0, the working directory and path have been normalized so that it will work properly when run from a subdirectory as well as the project root directory. Instead, it must now be run from under the project directory.

If you are in outside the project directory, you need to change the directory beforehand, or change the directory using the -c (--chdir) or -C (--directory) options.

The directory for specfile execution will be the project root directory by default.

The specfile that does not match the pattern

Specfiles that do not match --pattern are no longer executed, even if they are specified as arguments.

$HOME/.shellspec has been changed to $HOME/.shellspec-options

Changed to .shellspec-options to avoid recognizing the home directory as the project root directory.

New option parser

The option parser has been updated to allow POSIX and GNU compliant syntax.

shellspec --init

shellspec --init no longer generates a example specfile by default.

Self-executable specfile changes

It is now deprecated to specify shellspec as shebang for portability. (However, you can continue to use it at your own risk.)

[deprecated]
#!/usr/bin/env shellspec

Instead, Write the following line at the top of the file.

eval "$(shellspec - -c) exit 1"

You can use /bin/sh, /usr/bin/env bash, etc. for shebang. The specfile will be run in the shell written in shebang. This is the behavior from before.

Since the -c option is specified, there is no need to change the directory beforehand. Also, the --pattern option will be changed to *, so any file name can be executed. You can now pass other options as well.

It has been improved so that it will exit with an error when run in an environment where shellspec is not installed.

spec_helper changes

It has been greatly enhanced and it is now possible to specify the version of ShellSpec that can run specfiles.

shellspec_spec_helper_configure has been changed to spec_helper_configure. The old function names can still be used for a while to maintain compatibility.

The spec_helper will be loaded at least twice to achieve precheck. The functions that can be used in spec_helper have been clarified. Functions starting with shellspec_ are also available, but these are change without notice.

Environment variables

The SHELLSPEC_SPECDIR will be deprecated because there is no longer a single directory for specfiles. Instead, SHELLSPEC_HELPERDIR has been introduced. However, this is not the location of the specfiles, but the location of spec_helper, etc.