<commit_before>require 'spec_helper'

describe Sprig::Reap::Model do
  describe ".all" do
    let(:all_models) do
      [
        described_class.new(User),
        described_class.new(Tag),
        described_class.new(Post),
        described_class.new(Comment),
        described_class.new(Vote)
      ]
    end

    it "returns an dependency-sorted array of Sprig::Reap::Models" do
      described_class.all.all? { |model| model.is_a? Sprig::Reap::Model }.should == true
      described_class.all.map(&:klass).should == all_models.map(&:klass)
    end
  end

  describe ".find" do
    let!(:user)      { User.create(:first_name => 'Bo', :last_name => 'Janglez') }
    let!(:post1)     { Post.create }
    let!(:post2)     { Post.create }
    let!(:comment1)  { Comment.create(:post => post1) }
    let!(:comment2)  { Comment.create(:post => post2) }

    subject { described_class }

    it "returns the Sprig::Reap::Record for the given class and id" do
      subject.find(User, 1).record.should == user
      subject.find(Post, 1).record.should == post1
      subject.find(Post, 2).record.should == post2
      subject.find(Comment, 1).record.should == comment1
      subject.find(Comment, 2).record.should == comment2
    end
  end<commit_msg>Stub out the model input order -- seems to be causing failure on Travis CI<commit_after>require 'spec_helper'

describe Sprig::Reap::Model do
  describe ".all" do
    let(:all_models) do
      [
        described_class.new(User),
        described_class.new(Tag),
        described_class.new(Post),
        described_class.new(Comment),
        described_class.new(Vote)
      ]
    end

    before do
      Sprig::Reap.stub(:models).and_return([
        Sprig::Reap::Inputs::Model.new(Comment),
        Sprig::Reap::Inputs::Model.new(Post),
        Sprig::Reap::Inputs::Model.new(User),
        Sprig::Reap::Inputs::Model.new(Vote),
        Sprig::Reap::Inputs::Model.new(Tag)
      ])
    end

    it "returns an dependency-sorted array of Sprig::Reap::Models" do
      described_class.all.all? { |model| model.is_a? Sprig::Reap::Model }.should == true
      described_class.all.map(&:klass).should == all_models.map(&:klass)
    end
  end

  describe ".find" do
    let!(:user)      { User.create(:first_name => 'Bo', :last_name => 'Janglez') }
    let!(:post1)     { Post.create }
    let!(:post2)     { Post.create }
    let!(:comment1)  { Comment.create(:post => post1) }
    let!(:comment2)  { Comment.create(:post => post2) }

    subject { described_class }

    it "returns the Sprig::Reap::Record for the given class and id" do
      subject.find(User, 1).record.should == user
      subject.find(Post, 1).record.should == post1
      subject.find(Post, 2).record.should == post2
      subject.find(Comment, 1).record.should == comment1
      subject.find(Comment, 2).record.should == comment2
    end
  end
{'fraction_non_alphanumeric': 0.14858737356121382, 'fraction_numerical': 0.010463899546564353, 'mean_word_length': 2.9778085991678225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6592659', 'n_tokens_mistral': 953, 'n_tokens_neox': 940, 'n_words': 185}