summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Rakefile7
-rw-r--r--test/app_test.rb8
-rw-r--r--test/day_entry_test.rb36
-rw-r--r--test/test_helper.rb6
4 files changed, 57 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index 94e447a..5674830 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,3 +1,10 @@
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.libs << 'test'
+ t.test_files = FileList['test/*_test.rb']
+end
+
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
diff --git a/test/app_test.rb b/test/app_test.rb
new file mode 100644
index 0000000..1683b9c
--- /dev/null
+++ b/test/app_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+class AppTest < Test::Unit::TestCase
+
+ should "permit commands from the HCl::Commands module" do
+ app = HCl::App.new
+ assert HCl::Commands.instance_methods.all? { |c| app.command? c }
+ end
+end
diff --git a/test/day_entry_test.rb b/test/day_entry_test.rb
new file mode 100644
index 0000000..5c9b37d
--- /dev/null
+++ b/test/day_entry_test.rb
@@ -0,0 +1,36 @@
+require 'test_helper'
+
+class DayEntryTest < Test::Unit::TestCase
+ should "read DayEntry xml" do
+ entries = HCl::DayEntry.from_xml(<<-EOD)
+<daily>
+ <for_day type="date">Wed, 18 Oct 2006</for_day>
+ <day_entries>
+ <day_entry>
+ <id type="integer">195168</id>
+ <client>Iridesco</client>
+ <project>Harvest</project>
+ <task>Backend Programming</task>
+ <hours type="float">2.06</hours>
+ <notes>Test api support</notes>
+ <timer_started_at type="datetime">
+ Wed, 18 Oct 2006 09:53:06 -0000
+ </timer_started_at>
+ <created_at type="datetime">Wed, 18 Oct 2006 09:53:06 -0000</created_at>
+ </day_entry>
+ </day_entries>
+</daily>
+ 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
+
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..633c821
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,6 @@
+$:.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'test/unit'
+require 'hcl/app'
+require 'shoulda'
+require 'mocha'