<commit_before>require File.dirname(__FILE__) + '/test_helper'

class BlipTest < Test::Unit::TestCase

  context "a blip" do
    setup { @blip = Wave::Blip.new(:wavelet => new_wavelet) }
    should "have a wavelet" do
      assert @blip.wavelet
    end
    should "have a wave" do
      assert @blip.wave
    end
    should "have a creator" do
      assert @blip.creator
    end
    should "have a collection of child blips" do
      assert @blip.children
    end
    should "be root if it's the first blip in the wavelet" do
      assert @blip.root?
    end
    should "not have a parent if it's the root blip" do
      assert !@blip.parent
    end
    should "register itself in it's wavelet's blip collection" do
      assert @blip.wavelet.blips.include?(@blip)
    end
    context "made second" do
      setup { @second_blip = Wave::Blip.new(:wavelet => @blip.wavelet) }
      should "not be root" do
        assert !@second_blip.root?
      end
    end
    context "made as a child to another blip" do
      setup { @child_blip = Wave::Blip.new(:parent => @blip) }
      should "not be root" do
        assert !@child_blip.root?
      end
      should "have a proper parent blip" do
        assert_equal @blip, @child_blip.parent
      end
      should "be in the parent blip's collection of children" do
        assert @blip.children.include?(@child_blip)
      end
    end
  end

  protected

    def new_wavelet
      Wave::Wavelet.new(:wave => Wave.new("<EMAIL>"))
    end

end<commit_msg>adding :creator option to blip test<commit_after>require File.dirname(__FILE__) + '/test_helper'

class BlipTest < Test::Unit::TestCase

  context "a blip" do
    setup { @blip = new_blip }
    should "have a wavelet" do
      assert @blip.wavelet
    end
    should "have a wave" do
      assert @blip.wave
    end
    should "have a creator" do
      assert @blip.creator
    end
    should "have a collection of child blips" do
      assert @blip.children
    end
    should "be root if it's the first blip in the wavelet" do
      assert @blip.root?
    end
    should "not have a parent if it's the root blip" do
      assert !@blip.parent
    end
    should "register itself in it's wavelet's blip collection" do
      assert @blip.wavelet.blips.include?(@blip)
    end
    context "made second" do
      setup { @second_blip = new_blip(:wavelet => @blip.wavelet) }
      should "not be root" do
        assert !@second_blip.root?
      end
    end
    context "made as a child to another blip" do
      setup { @child_blip = new_blip(:parent => @blip) }
      should "not be root" do
        assert !@child_blip.root?
      end
      should "have a proper parent blip" do
        assert_equal @blip, @child_blip.parent
      end
      should "be in the parent blip's collection of children" do
        assert @blip.children.include?(@child_blip)
      end
    end
  end

  protected

    def new_blip(options = {})
      wavelet = options[:wavelet] || new_wavelet
      Wave::Blip.new(
        { :wavelet => wavelet,
          :creator => new_participant(:wavelet => wavelet)
        }.merge(options)
      )
    end

    def new_participant(options = {})
      Wave::Participant.new(:id => '<EMAIL>',
                            :wavelet => options[:wavelet] || new_wavelet)
    end

    def new_wavelet
      Wave::Wavelet.new(:wave => Wave.new("<EMAIL>"))
    end

end
{'fraction_non_alphanumeric': 0.09834123222748815, 'fraction_numerical': 0.0, 'mean_word_length': 2.3803803803803802, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 18, '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': '2594805', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1088, 'n_words': 346}