diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/app_test.rb | 3 | ||||
| -rw-r--r-- | test/command_test.rb | 9 | ||||
| -rw-r--r-- | test/day_entry_test.rb | 12 | ||||
| -rw-r--r-- | test/ext/capture_output.rb | 8 |
4 files changed, 22 insertions, 10 deletions
diff --git a/test/app_test.rb b/test/app_test.rb index 1fc1073..e6dbc3d 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -2,6 +2,7 @@ require 'test_helper' class AppTest < HCl::TestCase def setup + super # touch config to avoid triggering manual config FileUtils.mkdir_p HCl::App::HCL_DIR FileUtils.touch File.join(HCl::App::HCL_DIR, "config.yml") @@ -13,7 +14,7 @@ class AppTest < HCl::TestCase end def test_command_show - HCl::DayEntry.expects(:all).returns [HCl::DayEntry.new( + HCl::DayEntry.expects(:daily).returns [HCl::DayEntry.new( hours:'2.06', notes:'hi world', project:'App' )] HCl::App.command 'show' diff --git a/test/command_test.rb b/test/command_test.rb index dd6f440..56c7d93 100644 --- a/test/command_test.rb +++ b/test/command_test.rb @@ -4,6 +4,7 @@ class CommandTest < HCl::TestCase include HCl::Utility def setup + super @settings = {} end @@ -34,7 +35,7 @@ class CommandTest < HCl::TestCase end def test_show - HCl::DayEntry.expects(:all).returns([HCl::DayEntry.new({ + HCl::DayEntry.expects(:daily).returns([HCl::DayEntry.new({ hours:'2.06', notes: 'hi world', project: 'App' @@ -74,9 +75,9 @@ class CommandTest < HCl::TestCase def test_stop entry = stub - HCl::DayEntry.expects(:with_timer).returns(entry) - entry.expects(:append_note).with('all done') - entry.expects(:toggle) + register_uri(:get, '/daily', {day_entries:[{id:123,notes:'',hours:1,client:nil,project:nil,timer_started_at:DateTime.now}]}) + register_uri(:post, '/daily/update/123', {day_entry:{notes:'all done'}}) + register_uri(:get, '/daily/timer/123') stop 'all done' end diff --git a/test/day_entry_test.rb b/test/day_entry_test.rb index 6566a86..5b53463 100644 --- a/test/day_entry_test.rb +++ b/test/day_entry_test.rb @@ -1,19 +1,25 @@ require 'test_helper' class DayEntryTest < HCl::TestCase + def test_project_info + register_uri(:get, '/daily', {projects:[], day_entries:[{project_id:123}]}) + register_uri(:get, '/projects/123', {project:{name:'fun times'}}) + assert_equal 'fun times', HCl::DayEntry.today.first.project_info.name + end + def test_all_today_empty register_uri(:get, '/daily', {projects:[],day_entries:[]}) - assert HCl::DayEntry.all.empty? + assert HCl::DayEntry.today.empty? end def test_all_today register_uri(:get, '/daily', {projects:[], day_entries:[{id:1,note:'hi'}]}) - assert_equal 'hi', HCl::DayEntry.all.first.note + assert_equal 'hi', HCl::DayEntry.today.first.note end def test_all_with_date register_uri(:get, '/daily/013/2013', {projects:[], day_entries:[{id:1,note:'hi'}]}) - assert_equal 'hi', HCl::DayEntry.all(Date.civil(2013,1,13)).first.note + assert_equal 'hi', HCl::DayEntry.daily(Date.civil(2013,1,13)).first.note end def test_toggle diff --git a/test/ext/capture_output.rb b/test/ext/capture_output.rb index ee98808..930f408 100644 --- a/test/ext/capture_output.rb +++ b/test/ext/capture_output.rb @@ -1,11 +1,15 @@ module CaptureOutput def before_setup super - $stderr = @stderr = StringIO.new - $stdout = @stdout = StringIO.new + @stderr = StringIO.new + @stdout = StringIO.new + return if ENV['VERBOSE'] + $stderr = @stderr + $stdout = @stdout end def after_teardown super + return if ENV['VERBOSE'] $stderr = STDERR $stdout = STDOUT end |
