two_fer_test.sh (1115B)
1 #!/usr/bin/env bash 2 3 @test "no name given" { 4 #[[ $BATS_RUN_SKIPPED == true ]] || skip 5 6 # The above line controls whether to skip the test. 7 # Normally, we skip every test except for the first one 8 # (the first one is always commented out). This allows for 9 # a person to focus on solving a test at a time: you can 10 # comment out or delete the 11 # `[[ $BATS_RUN_SKIPPED == true ]] || skip` 12 # line to run the test when you are ready. 13 # 14 # You can also run the all the tests by setting the 15 # `$BATS_RUN_SKIPPED` environment variable, like this: 16 # 17 # $ BATS_RUN_SKIPPED=true bats two_fer_test.sh 18 19 run bash two_fer.sh 20 [ "$status" -eq 0 ] 21 [ "$output" == "One for you, one for me." ] 22 } 23 24 @test "a name given" { 25 run bash two_fer.sh Alice 26 [ "$status" -eq 0 ] 27 [ "$output" == "One for Alice, one for me." ] 28 } 29 30 @test "another name given" { 31 run bash two_fer.sh Bob 32 [ "$status" -eq 0 ] 33 [ "$output" == "One for Bob, one for me." ] 34 } 35 36 @test "handle arg1 properly" { 37 run bash two_fer.sh "John Smith" "Mary Ann" 38 [ "$status" -eq 0 ] 39 [ "$output" == "One for John Smith, one for me." ] 40 }