require 'test/unit' require 'app/helpers/tasks_helper' include Merb::TasksHelper class TaskHelperTestCase < Test::Unit::TestCase TERMINATORS = ["", "\n"] # Convenience assertion to check that get_bucket_tasks_from_text returns the # expected result for the given task text, also trying adding newlines at the # end def assert_correct_tasks(expected, task_text) TERMINATORS.each do |term| assert_equal expected, get_bucket_tasks_from_text(task_text + term) end end def test_single_simple_task assert_correct_tasks [["simple task", []]], "simple task" end def test_single_tagged_task assert_correct_tasks [["simple task", ["some_tag", "test"]]], "simple task [some_tag, test]" end def test_simple_tasks assert_correct_tasks [["first task", []], ["second task after empty line", []]], "first task \n" + "\n" + "second task after empty line" end def test_tagged_tasks assert_correct_tasks [["simple task", ["some_tag", "test"]], ["another task", ["test", "qa"]]], "simple task [some_tag , test]\n" + "another task [test,qa]" # Some task without tags in between assert_correct_tasks [["task with extra blanks", ["some_tag", "test"]], ["some task without tags", []], ["another task", ["test", "qa"]]], " task with extra blanks [some_tag, test] \n" + "some task without tags\n" + "another task [test,qa]" # With explicit empty tags assert_correct_tasks [["simple task", ["some_tag", "test"]], ["some task without tags", []], ["another task", ["test"]]], "simple task [some_tag , test]\n" + "some task without tags []\n" + "another task [test ,]" end end