require 'test_helper' class DayEntryTest < Test::Unit::TestCase def test_from_xml entries = HCl::DayEntry.from_xml(<<-EOD) Wed, 18 Oct 2006 195168 Iridesco Harvest Backend Programming 2.06 Test api support Wed, 18 Oct 2006 09:53:06 -0000 Wed, 18 Oct 2006 09:53:06 -0000 EOD assert_equal 1, entries.size { :project => 'Harvest', :client => 'Iridesco', :task => 'Backend Programming', :notes => 'Test api support', :hours => '2.06', }.each do |method, value| assert_equal value, entries.first.send(method) end end def test_append_note entry = HCl::DayEntry.new(:id => '1', :notes => 'yourmom.', :hours => '1.0') HCl::DayEntry.stubs(:post) entry.append_note('hi world') assert_equal "yourmom.\nhi world", entry.notes end def test_append_note_to_empty entry = HCl::DayEntry.new(:id => '1', :notes => nil, :hours => '1.0') HCl::DayEntry.stubs(:post) entry.append_note('hi world') assert_equal 'hi world', entry.notes end end