Skip to content

README: First assert() and refute() examples are backwards #40

Closed

Description

@stefanlasiewski

https://github.com/bats-core/bats-assert#assert and https://github.com/bats-core/bats-assert#refute both appear incorrect.

The docs say this assert example should fail, but it actually succeeds:

@test 'assert()' {
  touch '/var/log/test.log'
  assert [ -e '/var/log/test.log' ]
}

Same with the refute example:

@test 'refute()' {
  rm -f '/var/log/test.log'
  refute [ -e '/var/log/test.log' ]
}

But in reality, they both succeed:

stefanl@stefanl:~ $ libs/bats-core/bin/bats --pretty bats-test/bats-assert.bats
 ✓ assert()
 ✓ refute()

Activity

  1. martin-schulze-vireso commented on Nov 18, 2021

    @martin-schulze-vireso
    Member

    Reading the other examples I understand why you eypect These examples to show failures too. I think it would be sufficient to use something like [ 1 -eq 2 ] to showcase a guaranteed failure.

  2. martin-schulze-vireso commented on Dec 9, 2021

    @martin-schulze-vireso
    Member

    I opted for not using -eq because that is assert_equal territory.

  3. stefanlasiewski commented on Dec 9, 2021

    @stefanlasiewski
    Author

    Thanks Martin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions