summaryrefslogtreecommitdiff
path: root/test/test_timetrackr.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_timetrackr.rb')
-rw-r--r--test/test_timetrackr.rb50
1 files changed, 48 insertions, 2 deletions
diff --git a/test/test_timetrackr.rb b/test/test_timetrackr.rb
index b259c11..0c8a526 100644
--- a/test/test_timetrackr.rb
+++ b/test/test_timetrackr.rb
@@ -1,7 +1,53 @@
require 'helper'
class TestTimetrackr < Test::Unit::TestCase
- should "probably rename this file and start testing for real" do
- flunk "hey buddy, you should probably rename this file and start testing for real"
+ context 'a YAML based tracker' do
+ setup do
+ @config = {:path => '/tmp/timetracker.test'}
+ @t = TimeTrackr.create('yaml',@config)
+ end
+
+ def teardown
+ File.unlink(@config[:path]) rescue nil
+ end
+
+ should 'initialise a log file' do
+ assert File.exist?(@config[:path])
+ end
+
+ context 'with empty db' do
+ setup do
+ File.open(@config[:path]) do |fh|
+ @db = YAML.load(fh)
+ end
+ end
+
+ should 'create basic structure' do
+ File.open(@config[:path]) do |fh|
+ @db = YAML.load(fh)
+ end
+ assert @db[:current].class == Array
+ assert @db[:tasks].class == Hash
+ end
+
+ should 'not fail on current command' do
+ assert_nothing_raised Exception do
+ @t.current
+ end
+ end
+
+ should 'not fail on tasks command' do
+ assert_nothing_raised Exception do
+ @t.tasks
+ end
+ end
+
+ should 'not fail on close command' do
+ assert_nothing_raised Exception do
+ @t.close
+ end
+ end
+
+ end
end
end