<commit_before>require 'spec_helper'

describe "TaskHanlder::Project" do
  describe "#convert_projects_to_tasks" do
    it "converts projects to tasks as expected" do
      project = TaskHandler::Project.new
      projects = [
        {
          "project" =>  'project_name1',
          "tasks" => [
            {
              "task" => "task_name1",
              "due_date" => Date.new(2015, 1, 1),
              "status" => "open"
            }
          ],
        },
        {
          "project" => 'project_name2',
          "tasks" => [
            {
              "task" => "task_name2",
              "due_date" => Date.new(2015, 2, 1),
              "status" => "open"
            }
          ]
        }
      ]
      project.convert_projects_to_tasks(projects)

      expected = [
        {
          task_number: 0,
          project: "project_name1",
          task: "task_name1",
          duedate: Date.new(2015, 1, 1),
          status: "open"
        },
        {
          task_number: 1,
          project: "project_name2",
          task: "task_name2",
          duedate: Date.new(2015, 2, 1),
          status: "open"
        },
      ]

      expect(project.tasks).to match expected
    end
  end

  describe "#build_task" do
    it "raises error when invalid date passed as due date" do
      project = TaskHandler::Project.new
      expect do
        project.build_task(["test_project", "test_task", "2011-01-32"])
      end.to raise_error(ArgumentError)
    end
  end
<commit_msg>Add a spec for #build_task<commit_after>require 'spec_helper'

describe "TaskHanlder::Project" do
  describe "#convert_projects_to_tasks" do
    it "converts projects to tasks as expected" do
      project = TaskHandler::Project.new
      projects = [
        {
          "project" =>  'project_name1',
          "tasks" => [
            {
              "task" => "task_name1",
              "due_date" => Date.new(2015, 1, 1),
              "status" => "open"
            }
          ],
        },
        {
          "project" => 'project_name2',
          "tasks" => [
            {
              "task" => "task_name2",
              "due_date" => Date.new(2015, 2, 1),
              "status" => "open"
            }
          ]
        }
      ]
      project.convert_projects_to_tasks(projects)

      expected = [
        {
          task_number: 0,
          project: "project_name1",
          task: "task_name1",
          duedate: Date.new(2015, 1, 1),
          status: "open"
        },
        {
          task_number: 1,
          project: "project_name2",
          task: "task_name2",
          duedate: Date.new(2015, 2, 1),
          status: "open"
        },
      ]

      expect(project.tasks).to match expected
    end
  end

  describe "#build_task" do
    it "raises error when invalid date passed as due date" do
      project = TaskHandler::Project.new
      expect do
        project.build_task(["test_project", "test_task", "2011-01-32"])
      end.to raise_error(ArgumentError)
    end

    it "returns expected hash" do
      project = TaskHandler::Project.new
      task = project.build_task(["", "test_project", "test_task", "2015-08-01"])
      expected = {
        "project" => "test_project",
        "tasks" => [
          {
            "task" => "test_task",
            "due_date" => Date.parse("2015-08-01"),
            "status" => "open"
          }
        ]
      }
      expect(task).to match expected
    end
  end

{'fraction_non_alphanumeric': 0.12795389048991354, 'fraction_numerical': 0.02881844380403458, 'mean_word_length': 1.5409956076134699, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2089932', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1044, 'n_words': 224}