bats-core / bats-assert

Common assertions for Bats
Creative Commons Zero v1.0 Universal
96 stars 42 forks source link

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

Closed stefanlasiewski closed 2 years ago

stefanlasiewski commented 2 years ago

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()
martin-schulze-vireso commented 2 years ago

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.

martin-schulze-vireso commented 2 years ago

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

stefanlasiewski commented 2 years ago

Thanks Martin!