Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert expectation for custom assertion #72

Closed
ko1nksm opened this issue Jun 4, 2020 · 0 comments · Fixed by #75
Closed

Assert expectation for custom assertion #72

ko1nksm opened this issue Jun 4, 2020 · 0 comments · Fixed by #75
Labels
enhancement New feature or request

Comments

@ko1nksm
Copy link
Member

ko1nksm commented Jun 4, 2020

ShellSpec already has result of modifier for custom assertion. It can be assert using custom function. However, it can not pass arguments and you might want a simpler custom assertion.

Here are sample.

exists_docker_image() {
  docker inspect "$1" >/dev/null 2>&1
}

It "builds docker image"
  When run create_docker_image my_image
  Assert exists_docker_image my_image
End

Planned specifications

Difference between result of and Assert.

The result of is

  • custom assertion for result of evaluation.
    • That is, the arguments of the custom function are stdout, stderr, and status.

The Assert is

  • custom assertion for external side effects.
    • That is, the arguments of the custom function are passed as is.
  • You can not assert stdout/stderr/status of evaluation.
    • To be exact, it is possible by using the variable SHELLSPEC_STDOUT etc, But not recommend because it is internal variable.
  • Enable errexit before calling custom function.
    • To make it easy to assert without a return like bats.

NOTE: No plan to implement AssertEqual etc. Because it can be implemented with Assert.

Do you have any suggestion? or thumbs up if you like it.

@ko1nksm ko1nksm added enhancement New feature or request WORKING Work in progress labels Jun 6, 2020
@ko1nksm ko1nksm removed the WORKING Work in progress label Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant