<commit_before>require 'spec_helper'

describe PetitionStatistics do
  
  describe "when statistics are available" do        
    let(:google_data) { OpenStruct.new(:unique_pageviews=>"100") }
    let(:local_data) { OpenStruct.new(:signatures => 75, :new_members => 0) }
    let(:petition) { create(:petition_with_signatures, signature_count: 75) }
    subject { PetitionStatistics.new(petition, google_data, local_data) }
    
    its(:hit_count) { should == 100 }
    its(:signature_count) { should ==  75 }
    its(:new_member_count) { should ==  0 }
  end

  describe "when statistics are unavailable" do        
    let(:petition) { create(:petition_with_signatures, signature_count: 75) }
    let(:local_data) { OpenStruct.new(:signatures => 75, :new_members => 0) }
    subject { PetitionStatistics.new(petition, nil, local_data) }
    
    its(:hit_count) { should == 0 }
    its(:signature_count) { should ==  75 }
    its(:new_member_count) { should ==  0 }
  end
end<commit_msg>improved petition_statistics_spec performance<commit_after>require 'spec_helper'

describe PetitionStatistics do
  let(:google_data) { OpenStruct.new(:unique_pageviews=>"100") }
  let(:local_data) { OpenStruct.new(:signatures => 1, :new_members => 0) }
  let(:petition) { create(:petition_with_signatures, signature_count: 1) }
  
  describe "when statistics are available" do
    subject { PetitionStatistics.new(petition, google_data, local_data) }
    
    its(:hit_count) { should == 100 }
    its(:signature_count) { should ==  1 }
    its(:new_member_count) { should ==  0 }
  end

  describe "when statistics are unavailable" do        
    subject { PetitionStatistics.new(petition, nil, local_data) }
    
    its(:hit_count) { should == 0 }
    its(:signature_count) { should ==  1 }
    its(:new_member_count) { should ==  0 }
  end
end
{'fraction_non_alphanumeric': 0.12581699346405228, 'fraction_numerical': 0.020152505446623094, 'mean_word_length': 4.005449591280654, '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': '1069203', 'n_tokens_mistral': 614, 'n_tokens_neox': 563, 'n_words': 124}