From 26ea694048faaad292152b246f24d25eab0cf2ac Mon Sep 17 00:00:00 2001 From: Zack Hobson Date: Thu, 26 Dec 2013 21:39:52 -0800 Subject: timesheet_resource: resource scopes --- test/app_test.rb | 3 ++- test/command_test.rb | 3 ++- test/day_entry_test.rb | 6 +++--- test/ext/capture_output.rb | 8 ++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) (limited to 'test') 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..cd21736 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' diff --git a/test/day_entry_test.rb b/test/day_entry_test.rb index baa4f3b..0e391fa 100644 --- a/test/day_entry_test.rb +++ b/test/day_entry_test.rb @@ -3,17 +3,17 @@ require 'test_helper' class DayEntryTest < HCl::TestCase 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 a469e21..bbf5424 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 -- cgit v1.2.3