<commit_before>require 'spec_helper'

module Dotify
  describe Collection do

    let(:collection) { Collection.new }
    let(:home_files) {
      [
        @bashrc = double('unit1', :filename => '.bashrc', :linked? => false),
        @gitconfig = double('unit2', :filename => '.gitconfig', :linked? => false),
        @vimrc = double('unit3', :filename => '.vimrc', :linked? => true),
      ]
    }
    describe "methods" do
      %w[linked unlinked].each do |name|
        it "should respond to #{name}" do
          collection.should respond_to name
        end
      end
    end

    it "should pull the right files from Filter.home" do
      files = [stub, stub, stub]
      Filter.stub(:home).and_return files
      collection.units.should == files
    end

    describe Collection, "#linked" do
      before do
        Filter.stub(:home).and_return home_files
      end
      let(:linked) { collection.linked }
      it "should return the right Units" do
        linked.should include @vimrc
        linked.should_not include @gitconfig
        linked.should_not include @bashrc
      end
      it "should yield the correct Units" do
        expect { |b| collection.linked.each(&b) }.to yield_successive_args(*linked)
      end
    end

    describe Collection, "#unlinked" do
      before do
        Filter.stub(:home).and_return home_files
      end
      let(:unlinked) { collection.unlinked }
      it "should return the right Units" do
        unlinked.should include @gitconfig
        unlinked.should include @bashrc
        unlinked.should_not include @vimrc
      end
      it "should yield the correct Units" do
        expect { |b| collection.unlinked.each(&b) }.to yield_successive_args(*unlinked)
      end
    end

    it "should call #to_s on the units" do
      collection.units.should_receive(:to_s)
      collection.to_s<commit_msg>stubbing on collection and not filter in collection_spec<commit_after>require 'spec_helper'

module Dotify
  describe Collection do

    let(:collection) { Collection.new }
    let(:home_files) {
      [
        @bashrc = double('unit1', :filename => '.bashrc', :linked? => false),
        @gitconfig = double('unit2', :filename => '.gitconfig', :linked? => false),
        @vimrc = double('unit3', :filename => '.vimrc', :linked? => true),
      ]
    }
    describe "methods" do
      %w[linked unlinked].each do |name|
        it "should respond to #{name}" do
          collection.should respond_to name
        end
      end
    end

    it "should pull the right files from Filter.home" do
      files = [stub, stub, stub]
      Filter.stub(:home).and_return files
      collection.units.should == files
    end

    describe Collection, "#linked" do
      before do
        collection.stub(:units).and_return home_files
      end
      let(:linked) { collection.linked }
      it "should return the right Units" do
        linked.should include @vimrc
        linked.should_not include @gitconfig
        linked.should_not include @bashrc
      end
      it "should yield the correct Units" do
        expect { |b| collection.linked.each(&b) }.to yield_successive_args(*linked)
      end
    end

    describe Collection, "#unlinked" do
      before do
        collection.stub(:units).and_return home_files
      end
      let(:unlinked) { collection.unlinked }
      it "should return the right Units" do
        unlinked.should include @gitconfig
        unlinked.should include @bashrc
        unlinked.should_not include @vimrc
      end
      it "should yield the correct Units" do
        expect { |b| collection.unlinked.each(&b) }.to yield_successive_args(*unlinked)
      end
    end

    it "should call #to_s on the units" do
      collection.units.should_receive(:to_s)
      collection.to_s
{'fraction_non_alphanumeric': 0.10140695513671356, 'fraction_numerical': 0.0015927794000530925, 'mean_word_length': 2.4824399260628467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3285596', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1073, 'n_words': 324}