<commit_before>require 'rails_helper'

describe Peer do
  it { should belong_to(:peer1)}
  it { should belong_to(:peer2)}
  it { should belong_to(:peer3)}
  it { should belong_to(:peer4)}

  it "can get users" do
    FactoryGirl.create(:user).should be_valid
  end
 
  before{100.times{FactoryGirl.create(:user)}}
  it "Should have a database of 300 users" do
    expect(User.all.count).to eq(100)
  end 

  context "#generate_groups" do
    it "Should loop through all the users and make groups" do
      start_group = User.where(is_participating_this_month: true, waitlist: false, live_in_detroit: true, is_assigned_peer_group: true)
      Peer.generate_groups
      remainder = User.where(is_participating_this_month: true, waitlist: false, live_in_detroit: true, is_assigned_peer_group: false)
      expect(start_group.length > 0).to eq(true)
      expect(remainder.length).to eq(0)
      all_peers_in_groups = Peer.all.each {||}
    end
  end

  context "#automatially_create_groups" do
    it "should loop through and assign groups" do
      start_group = User.where(is_participating_this_month: true, waitlist: false, live_in_detroit: true)
      groups = Peer.automatially_create_groups
      groups.each do |group|
        expect(group.length < 3).to be(false)
      end
      expect(groups.flatten.length).to eq(start_group.length)
    end
  end

  context "#self.get_peers" do<commit_msg>removing unneeded line from rspec<commit_after>require 'rails_helper'

describe Peer do
  it { should belong_to(:peer1)}
  it { should belong_to(:peer2)}
  it { should belong_to(:peer3)}
  it { should belong_to(:peer4)}

  it "can get users" do
    FactoryGirl.create(:user).should be_valid
  end
 
  before{100.times{FactoryGirl.create(:user)}}
  it "Should have a database of 300 users" do
    expect(User.all.count).to eq(100)
  end 

  context "#generate_groups" do
    it "Should loop through all the users and make groups" do
      start_group = User.where(is_participating_this_month: true, waitlist: false, live_in_detroit: true, is_assigned_peer_group: true)
      Peer.generate_groups
      remainder = User.where(is_participating_this_month: true, waitlist: false, live_in_detroit: true, is_assigned_peer_group: false)
      expect(start_group.length > 0).to eq(true)
      expect(remainder.length).to eq(0)
    end
  end

  context "#automatially_create_groups" do
    it "should loop through and assign groups" do
      start_group = User.where(is_participating_this_month: true, waitlist: false, live_in_detroit: true)
      groups = Peer.automatially_create_groups
      groups.each do |group|
        expect(group.length < 3).to be(false)
      end
      expect(groups.flatten.length).to eq(start_group.length)
    end
  end

  context "#self.get_peers" do
{'fraction_non_alphanumeric': 0.09563334536268495, 'fraction_numerical': 0.01154817755322988, 'mean_word_length': 3.9236234458259327, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4299359', 'n_tokens_mistral': 951, 'n_tokens_neox': 900, 'n_words': 229}