Navigation Menu

Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jergason committed Aug 11, 2012
1 parent 372566f commit 8c7bf47
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -59,3 +59,12 @@ $ badoop
```

Consider it clouded.

## Contributing

Run the tests with `./test`. Make sure you have [roundup](https://github.com/bmizerany/roundup/)
to run them. If you add new features, add new tests for them please.

## TODOS

* `npm test` doesn't like roundup. The tests never exit.
43 changes: 43 additions & 0 deletions badoop-test.sh
@@ -0,0 +1,43 @@
#! /usr/bin/env roundup

describe 'badoop: todo list management in bash'

badoop='./badoop'

set_up_test_file() {
TODO=./test_todo.txt
}

tear_down_test_file() {
rm "$TODO"
if [[ -f "$TODO-e" ]]; then
# sometimes sed creates these weird files
rm "$TODO-e"
fi
unset TODO
}

it_prints_usage() {
$badoop -h | grep -- '-h'
}

it_doesnt_error_if_file_doesnt_exist() {
set_up_test_file
$badoop
}

it_prints_out_contents_of_todos_when_no_args_give() {
set_up_test_file
echo "HURP DURP" >> "$TODO"
$badoop | grep 'HURP DURP'
tear_down_test_file
}

it_deletes_todos_matching_arguments() {
set_up_test_file
echo "SOME STUFF" >> "$TODO"
$badoop -d SOME
res="$($badoop)"
test "$res" = ""
tear_down_test_file
}
4 changes: 2 additions & 2 deletions package.json
@@ -1,9 +1,9 @@
{
"name": "badoop",
"version": "0.0.0",
"version": "0.0.1",
"description": "Todo list management in bash",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "./test"
},
"repository": {
"type": "git",
Expand Down
17 changes: 17 additions & 0 deletions test
@@ -0,0 +1,17 @@
#! /usr/bin/env bash

# vim:filetype=sh

roundup=$(which roundup)

[[ ! -z "$roundup" ]] || {
cat <<MESSAGE 1>&2 ;
error: roundup missing
Look at https://github.com/bmizerany/roundup for instructions on installing roundup.
MESSAGE

exit 1;
}

$roundup ./*-test.sh

0 comments on commit 8c7bf47

Please sign in to comment.