Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add tests

  • Loading branch information...
commit 8c7bf4794368655c97fee51d8a4682e4b0391b40 1 parent 372566f
@jergason authored
Showing with 71 additions and 2 deletions.
  1. +9 −0 README.md
  2. +43 −0 badoop-test.sh
  3. +2 −2 package.json
  4. +17 −0 test
View
9 README.md
@@ -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.
View
43 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
+}
View
4 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",
View
17 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
Please sign in to comment.
Something went wrong with that request. Please try again.