<commit_before>require 'rails_helper'
require 'active_support/time'

describe AssistanceEligibility do

  before(:all) do

    @assistance_eligibility = AssistanceEligibility.new

    deduction1 = Deduction.new
    deduction1.amount_in_cents = 470
    deduction1.start_date = Date.new(2013, 01, 01)
    deduction1.end_date = nil
    deduction1.frequency = "yearly"


    income1 = Income.new
    income1.amount_in_cents = 111400
    income1.start_date = Date.new(2012, 04, 12)
    income1.end_date = nil
    income1.frequency = "monthly"

    income2 = Income.new
    income2.amount_in_cents = 120030
    income2.start_date = Date.new(2013, 10, 02)
    income2.end_date = nil
    income2.frequency = "monthly"

    income3 = Income.new
    income3.amount_in_cents = 111400
    income3.start_date = nil
    income3.end_date = nil
    income3.frequency = "monthly"

    income4 = Income.new
    income4.amount_in_cents = 120030
    income4.start_date = nil
    income4.end_date = nil
    income4.frequency = "monthly"

    @assistance_eligibility.incomes << income1 << income2 << income3 << income4


    @assistance_eligibility.deductions << deduction1



end

  context "yearwise income computation" do
    it "should compute the income hash" do
      income_hash = @assistance_eligibility.compute_yearwise(@assistance_eligibility.incomes)
      puts income_hash.inspect
      expect(((income_hash[2014]) - 5553600).abs).to be < 1000
    end
  end

  context "yearwise deductions computation" do
    it "should compute the deductions hash" do
      deduction_hash = @assistance_eligibility.compute_yearwise(@assistance_eligibility.deductions)
      puts deduction_hash.inspect
      expect((deduction_hash[2014]) - 470).to be < 1000
    end
  end

end<commit_msg>using .abs in matcher<commit_after>require 'rails_helper'
require 'active_support/time'

describe AssistanceEligibility do

  before(:all) do

    @assistance_eligibility = AssistanceEligibility.new

    deduction1 = Deduction.new
    deduction1.amount_in_cents = 470
    deduction1.start_date = Date.new(2013, 01, 01)
    deduction1.end_date = nil
    deduction1.frequency = "yearly"


    income1 = Income.new
    income1.amount_in_cents = 111400
    income1.start_date = Date.new(2012, 04, 12)
    income1.end_date = nil
    income1.frequency = "monthly"

    income2 = Income.new
    income2.amount_in_cents = 120030
    income2.start_date = Date.new(2013, 10, 02)
    income2.end_date = nil
    income2.frequency = "monthly"

    income3 = Income.new
    income3.amount_in_cents = 111400
    income3.start_date = nil
    income3.end_date = nil
    income3.frequency = "monthly"

    income4 = Income.new
    income4.amount_in_cents = 120030
    income4.start_date = nil
    income4.end_date = nil
    income4.frequency = "monthly"

    @assistance_eligibility.incomes << income1 << income2 << income3 << income4


    @assistance_eligibility.deductions << deduction1



end

  context "yearwise income computation" do
    it "should compute the income hash" do
      income_hash = @assistance_eligibility.compute_yearwise(@assistance_eligibility.incomes)
      expect(((income_hash[2014]) - 5553600).abs).to be < 1000
    end
  end

  context "yearwise deductions computation" do
    it "should compute the deductions hash" do
      deduction_hash = @assistance_eligibility.compute_yearwise(@assistance_eligibility.deductions)
      expect(((deduction_hash[2014]) - 470).abs).to be < 1000
    end
  end

end
{'fraction_non_alphanumeric': 0.08575539568345324, 'fraction_numerical': 0.06158273381294964, 'mean_word_length': 3.5142857142857142, 'pattern_counts': {'":': 0, '<': 27, '<?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': '2878412', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1105, 'n_words': 238}