<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'one40_proof/multi'

describe "MultiBase" do
  before(:all) do
    hydra = Typhoeus::Hydra.new
    test_response = Response.new(:code => 200, :body => test_ad_data)
    user_response = Response.new(:code => 200, :body => user_ad_data)
    
    # I receive undefined method `request=' for #<WebMock::Response:0x7fc658> without these:
    test_response.stub!(:request=)
    user_response.stub!(:request=)
    
    hydra.stub(:get, "http://api.140proof.com/test/ads.json").and_return(test_response)
    hydra.stub(:get, "http://api.140proof.com/ads/user.json?app_id=test&user_id=sferik").and_return(user_response)
    hydra.stub(:get, "http://api.140proof.com/ads/search.json?app_id=test&q=New+York+Mets&user_id=sferik").and_return(user_response)
    
    Typhoeus::Hydra.stub!(:new).and_return(hydra)
    
    @a = One40Proof::Multi::Base.new(queries)
    @a.ads.should be_an(Array)
  end
    
  it "should return an Array of Ads" do
    @a.ads.should be_an(Array)
  end
  
  it "should create 3 ads" do
    @a.ads.size.should == 3
  end
  
  def queries
    [
      {:method => :test},
      {:method => :user, :user_id => 'sferik', :app_id => 'test'},<commit_msg>give variable a proper name and remove the already existing test<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require 'one40_proof/multi'

describe "MultiBase" do
  before(:all) do
    hydra = Typhoeus::Hydra.new
    test_response = Response.new(:code => 200, :body => test_ad_data)
    user_response = Response.new(:code => 200, :body => user_ad_data)
    
    # I receive undefined method `request=' for #<WebMock::Response:0x7fc658> without these:
    test_response.stub!(:request=)
    user_response.stub!(:request=)
    
    hydra.stub(:get, "http://api.140proof.com/test/ads.json").and_return(test_response)
    hydra.stub(:get, "http://api.140proof.com/ads/user.json?app_id=test&user_id=sferik").and_return(user_response)
    hydra.stub(:get, "http://api.140proof.com/ads/search.json?app_id=test&q=New+York+Mets&user_id=sferik").and_return(user_response)
    
    Typhoeus::Hydra.stub!(:new).and_return(hydra)
    
    @response = One40Proof::Multi::Base.new(queries)
  end
    
  it "should return an Array of Ads" do
    @response.ads.should be_an(Array)
  end
  
  it "should create 3 ads" do
    @response.ads.size.should == 3
  end
  
  def queries
    [
      {:method => :test},
      {:method => :user, :user_id => 'sferik', :app_id => 'test'},
{'fraction_non_alphanumeric': 0.16073523660539696, 'fraction_numerical': 0.02033633163863903, 'mean_word_length': 3.891013384321224, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6420721', 'n_tokens_mistral': 982, 'n_tokens_neox': 950, 'n_words': 157}