<commit_before>require 'rails_helper'
require 'database_cleaner'

DatabaseCleaner.strategy = :truncation

describe 'Tasks requests' do
  before(:all) do
    DatabaseCleaner.clean
    @users = FactoryGirl.create_list(:user, 5)
    @projects = FactoryGirl.create_list(:project, 10)
    @project = @projects.first
    @project.tasks << FactoryGirl.create_list(:task, 5)
    @task = @project.tasks.first
  end

  describe '#index' do
    it 'gets all the tasks for a project' do
      get "/projects/#{@project.id}/tasks"
      expect(response).to be_success
      tasks_json = JSON.parse(response.body)
      expect(tasks_json.length).to eq 5
    end
  end

  describe '#show' do
    it 'should retrieve a single task by id and return json' do
      get "/tasks/#{@task.id}"
      expect(response).to be_success
      task_json = JSON.parse(response.body)
      expect(task_json['title']).to eq @task.title
    end
  end

end<commit_msg>improve #show test<commit_after>require 'rails_helper'
require 'database_cleaner'

DatabaseCleaner.strategy = :truncation

describe 'Tasks requests' do
  before(:all) do
    DatabaseCleaner.clean
    @users = FactoryGirl.create_list(:user, 5)
    @projects = FactoryGirl.create_list(:project, 10)
    @project = @projects.first
    @project.tasks << FactoryGirl.create_list(:task, 5)
    @task = @project.tasks.first
  end

  describe '#index' do
    it 'gets all the tasks for a project' do
      get "/projects/#{@project.id}/tasks"
      expect(response).to be_success
      tasks_json = JSON.parse(response.body)
      expect(tasks_json.length).to eq 5
    end
  end

  describe '#show' do
    it 'should retrieve a single task by id and return json' do
      get "/tasks/#{@task.id}"
      expect(response).to be_success
      task_json = JSON.parse(response.body)
      expect(task_json['id']).to eq @task.id
      expect(task_json['completed']).to eq @task.completed
      expect(task_json['priority']).to eq @task.priority
      expect(task_json['priority']).to eq @task.priority
      expect(task_json['title']).to eq @task.title
      expect(task_json['title']).to eq @task.title
      expect(task_json['description']).to eq @task.description
    end
  end

end
{'fraction_non_alphanumeric': 0.12108843537414966, 'fraction_numerical': 0.0045351473922902496, 'mean_word_length': 3.4208416833667337, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6482950', 'n_tokens_mistral': 718, 'n_tokens_neox': 687, 'n_words': 173}