<commit_before><commit_msg>port Rel spec to minitest/spec<commit_after>require_relative '../spec_helper'

module Relentity describe Rel do

  before do
    @sam   = People[:sam]
    @sybil = People[:sybil]
    @y_sam = People[:y_sam]
    @duchy = Rels[:duchy]
    @cow   = Rels[:cow]
  end

  describe '.new' do

    it 'adds the new Rel to Rels' do
      sam_self = Rel.new id: :sam_self, refs: [@y_sam, @y_sam]
      Rels[:sam_self].must_be_same_as sam_self
    end

    it 'references passed-in refs' do
      @duchy.instance_variable_get(:@properties)[:refs].must_equal [{ref: 'People', id: :sam}, {ref: 'People', id: :sybil}]
    end

  end

  describe '#other' do

    it 'returns the other Entity' do
      @duchy.other(@sam).must_be_same_as @sybil
      @duchy.other(@sybil).must_be_same_as @sam
      @duchy.other(@y_sam).must_be_nil
    end

  end

  describe '#refs' do

    it 'dereferences internal refs' do
      @duchy.refs.must_equal [@sam, @sybil]
    end

  end

  describe '#refs=' do

    it 'references passed-in refs' do
      chudy = @duchy.dup
      chudy.refs = [@sybil, @sam]
      chudy.instance_variable_get(:@properties)[:refs].must_equal [{ref: 'People', id: :sybil}, {ref: 'People', id: :sam}]
    end

  end

  describe '#refs?' do

    it 'is a predicate whether the Rel refs the given Entity' do
      assert @duchy.refs? @sam
      assert @duchy.refs? @sybil
      refute @duchy.refs? @y_sam
    end

  end

  describe '#rel_to_other' do

    it 'returns the relationship to the Entity other than the passed one' do
      @duchy.rel_to_other(@sam).must_equal :spouses
      @duchy.rel_to_other(@sybil).must_equal :spouses
      @duchy.rel_to_other(@y_sam).must_be_nil

      @cow.rel_to_other(@sam).must_equal :children
      @cow.rel_to_other(@y_sam).must_equal :parents
      @cow.rel_to_other(@sybil).must_be_nil
    end

  end

end end

{'fraction_non_alphanumeric': 0.12533333333333332, 'fraction_numerical': 0.0, 'mean_word_length': 3.0606060606060606, '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': '7218687', 'n_tokens_mistral': 732, 'n_tokens_neox': 686, 'n_words': 170}