2011-12-28 23:21:48 +01:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
|
|
|
|
|
2011-12-29 00:12:17 +01:00
|
|
|
@test "no arguments prints usage instructions" {
|
2011-12-28 23:21:48 +01:00
|
|
|
run bats
|
2011-12-29 01:25:05 +01:00
|
|
|
[ $status -eq 1 ]
|
|
|
|
[ $(expr "$output" : "usage:") -ne 0 ]
|
2011-12-28 23:21:48 +01:00
|
|
|
}
|
|
|
|
|
2011-12-29 00:12:17 +01:00
|
|
|
@test "invalid filename prints an error" {
|
2011-12-28 23:21:48 +01:00
|
|
|
run bats nonexistent
|
2011-12-29 01:25:05 +01:00
|
|
|
[ $status -eq 1 ]
|
|
|
|
[ $(expr "$output" : ".*does not exist") -ne 0 ]
|
2011-12-28 23:21:48 +01:00
|
|
|
}
|
|
|
|
|
2011-12-29 00:12:17 +01:00
|
|
|
@test "empty test file runs zero tests" {
|
2011-12-28 23:21:48 +01:00
|
|
|
run bats "$FIXTURE_ROOT/empty.bats"
|
2011-12-29 01:25:05 +01:00
|
|
|
[ $status -eq 0 ]
|
|
|
|
[ $output = "1..0" ]
|
2011-12-28 23:21:48 +01:00
|
|
|
}
|
2011-12-29 00:12:37 +01:00
|
|
|
|
|
|
|
@test "one passing test" {
|
|
|
|
run bats "$FIXTURE_ROOT/one_passing.bats"
|
2011-12-29 01:25:05 +01:00
|
|
|
[ $status -eq 0 ]
|
|
|
|
[ ${lines[0]} = "1..1" ]
|
|
|
|
[ ${lines[1]} = "ok 1 a passing test" ]
|
2011-12-29 00:12:37 +01:00
|
|
|
}
|