<commit_before>require 'spec_helper'

describe "*** Query methods (based on spec/genealogy/sample_pedigree*.pdf files) *** ", :done, :query do

  before { @model = get_test_model({current_spouse: true})}
  include_context "pedigree exists"

  describe "class methods" do
    describe ".males" do
      specify do
        all_males = [ruben, paul, peter, paso, manuel, john, jack, bob, tommy, luis, larry, ned, steve, marcel, julian, rud, mark, sam, charlie]
        expect(@model.males.all).to match_array all_males
      end
    end
    describe ".females" do
      specify do
        all_females = [titty, mary, barbara, irene, terry, debby, alison, maggie, emily, rosa, louise, naomi, michelle, beatrix, mia, sue]
        expect(@model.females.all).to match_array all_females
      end
    end
    describe ".all_with" do
      context 'with argument :father' do
        specify { expect(@model.all_with(:father)).to match_array [irene, beatrix, julian, mary, peter, ruben, steve, mark, rud, titty, michelle, charlie, sam, sue, terry, paul, emily, tommy, barbara, john, paso, debby, jack] }
      end
      context 'with argument :mother' do
        specify { expect(@model.all_with(:mother)).to match_array [john, paso, mary, irene, mark, rud, titty, debby, jack, tommy, barbara, charlie, sam, sue, beatrix, julian, michelle, emily, paul, peter, steve] }
      end
      context 'with argument :parents' do
        specify { expect(@model.all_with(:parents)).to match_array [john, paso, mary, irene, mark, rud, titty, debby, jack, tommy, barbara, charlie, sam, sue, beatrix, julian, michelle, emily, paul, peter, steve] }
      end
    end
  end

  describe "peter" do
    subject {peter}
    context "if he hadn't parents" do
      before { peter.remove_parents }
      its(:parents) { is_expected.to match_array [nil, nil]}
      its(:paternal_grandfather) {is_expected.to be_nil}
      its(:paternal_grandmother) {is_expected.to be_nil}
      its(:maternal_grandfather) {is_expected.to be_nil}
      its(:maternal_grandmother) {is_expected.to be_nil}
      its(:grandparents) {is_expected.to match_array [nil, nil, nil, nil]}
      its(:siblings) {is_expected.to be_empty}
      its(:paternal_grandparents) {is_expected.to match_array [nil, nil]}
      its(:maternal_grandparents) {is_expected.to match_array [nil, nil]}
      its(:half_siblings) {is_expected.to be_empty}
      its(:ancestors) {is_expected.to be_empty}
      its(:uncles) {is_expected.to be_empty}
      its(:maternal_uncles) {is_expected.to be_empty}
      its(:paternal_uncles) {is_expected.to be_empty}
      its(:great_grandparents) {is_expected.to match_array [nil, nil, nil, nil, nil, nil, nil, nil]}
      its(:family) {is_expected.to be_empty}
    end
    its(:parents) { is_expected.to match_array [paul, titty]}
    its(:paternal_grandfather) {is_expected.to eq manuel}
    its(:paternal_grandmother) {is_expected.to eq terry}
    its(:maternal_grandfather) {is_expected.to eq paso}
    its(:maternal_grandmother) {is_expected.to eq irene}
    its(:grandparents) {is_expected.to match_array [manuel, terry, paso, irene]}
    its(:siblings) {is_expected.to match_array [steve]}
    its(:paternal_grandparents) {is_expected.to match_array [manuel, terry]}
    its(:maternal_grandparents) {is_expected.to match_array [paso, irene]}
    its(:half_siblings) {is_expected.to match_array [ruben, mary, julian, beatrix]}
    its(:uncles) {is_expected.to match_array [mark, rud]}
    its(:maternal_uncles) {is_expected.to match_array [mark, rud]}
    its(:paternal_uncles) {is_expected.to be_empty}
    its(:great_grandparents) {is_expected.to match_array [nil, nil, marcel, nil, jack, alison, tommy, emily]}
    describe "ancestors" do
      it {expect(peter.ancestors).to match_array([paul, titty, manuel, terry, paso, irene, tommy, emily, larry, louise, luis, rosa, marcel, bob, jack, alison])}
      context "with options generations: 1" do
        specify { expect(peter.ancestors(generations: 1)).to  match_array([paul, titty])}
      end
      context "with options generations: 2" do
        specify { expect(peter.ancestors(generations: 2)).to  match_array([paul, titty, manuel, terry, paso, irene])}
      end
    end
    describe "cousins" do
      it { expect(peter.cousins).to match_array([sam, charlie, sue])}<commit_msg>added a test for when generations options is 0 in #ancestors<commit_after>require 'spec_helper'

describe "*** Query methods (based on spec/genealogy/sample_pedigree*.pdf files) *** ", :done, :query do

  before { @model = get_test_model({current_spouse: true})}
  include_context "pedigree exists"

  describe "class methods" do
    describe ".males" do
      specify do
        all_males = [ruben, paul, peter, paso, manuel, john, jack, bob, tommy, luis, larry, ned, steve, marcel, julian, rud, mark, sam, charlie]
        expect(@model.males.all).to match_array all_males
      end
    end
    describe ".females" do
      specify do
        all_females = [titty, mary, barbara, irene, terry, debby, alison, maggie, emily, rosa, louise, naomi, michelle, beatrix, mia, sue]
        expect(@model.females.all).to match_array all_females
      end
    end
    describe ".all_with" do
      context 'with argument :father' do
        specify { expect(@model.all_with(:father)).to match_array [irene, beatrix, julian, mary, peter, ruben, steve, mark, rud, titty, michelle, charlie, sam, sue, terry, paul, emily, tommy, barbara, john, paso, debby, jack] }
      end
      context 'with argument :mother' do
        specify { expect(@model.all_with(:mother)).to match_array [john, paso, mary, irene, mark, rud, titty, debby, jack, tommy, barbara, charlie, sam, sue, beatrix, julian, michelle, emily, paul, peter, steve] }
      end
      context 'with argument :parents' do
        specify { expect(@model.all_with(:parents)).to match_array [john, paso, mary, irene, mark, rud, titty, debby, jack, tommy, barbara, charlie, sam, sue, beatrix, julian, michelle, emily, paul, peter, steve] }
      end
    end
  end

  describe "peter" do
    subject {peter}
    context "if he hadn't parents" do
      before { peter.remove_parents }
      its(:parents) { is_expected.to match_array [nil, nil]}
      its(:paternal_grandfather) {is_expected.to be_nil}
      its(:paternal_grandmother) {is_expected.to be_nil}
      its(:maternal_grandfather) {is_expected.to be_nil}
      its(:maternal_grandmother) {is_expected.to be_nil}
      its(:grandparents) {is_expected.to match_array [nil, nil, nil, nil]}
      its(:siblings) {is_expected.to be_empty}
      its(:paternal_grandparents) {is_expected.to match_array [nil, nil]}
      its(:maternal_grandparents) {is_expected.to match_array [nil, nil]}
      its(:half_siblings) {is_expected.to be_empty}
      its(:ancestors) {is_expected.to be_empty}
      its(:uncles) {is_expected.to be_empty}
      its(:maternal_uncles) {is_expected.to be_empty}
      its(:paternal_uncles) {is_expected.to be_empty}
      its(:great_grandparents) {is_expected.to match_array [nil, nil, nil, nil, nil, nil, nil, nil]}
      its(:family) {is_expected.to be_empty}
    end
    its(:parents) { is_expected.to match_array [paul, titty]}
    its(:paternal_grandfather) {is_expected.to eq manuel}
    its(:paternal_grandmother) {is_expected.to eq terry}
    its(:maternal_grandfather) {is_expected.to eq paso}
    its(:maternal_grandmother) {is_expected.to eq irene}
    its(:grandparents) {is_expected.to match_array [manuel, terry, paso, irene]}
    its(:siblings) {is_expected.to match_array [steve]}
    its(:paternal_grandparents) {is_expected.to match_array [manuel, terry]}
    its(:maternal_grandparents) {is_expected.to match_array [paso, irene]}
    its(:half_siblings) {is_expected.to match_array [ruben, mary, julian, beatrix]}
    its(:uncles) {is_expected.to match_array [mark, rud]}
    its(:maternal_uncles) {is_expected.to match_array [mark, rud]}
    its(:paternal_uncles) {is_expected.to be_empty}
    its(:great_grandparents) {is_expected.to match_array [nil, nil, marcel, nil, jack, alison, tommy, emily]}
    describe "ancestors" do
      it {expect(peter.ancestors).to match_array([paul, titty, manuel, terry, paso, irene, tommy, emily, larry, louise, luis, rosa, marcel, bob, jack, alison])}
      context "with options generations: 0" do
        specify { expect(peter.ancestors(generations: 0)).to  match_array([])}
      end
      context "with options generations: 1" do
        specify { expect(peter.ancestors(generations: 1)).to  match_array([paul, titty])}
      end
      context "with options generations: 2" do
        specify { expect(peter.ancestors(generations: 2)).to  match_array([paul, titty, manuel, terry, paso, irene])}
      end
    end
    describe "cousins" do
      it { expect(peter.cousins).to match_array([sam, charlie, sue])}
{'fraction_non_alphanumeric': 0.12254400908574674, 'fraction_numerical': 0.001249290176036343, 'mean_word_length': 4.020524515393387, 'pattern_counts': {'":': 0, '<': 3, '<?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': '232181', 'n_tokens_mistral': 3144, 'n_tokens_neox': 3081, 'n_words': 796}