<commit_before>require 'spec_helper'
require 'pry'

describe NaicsScraper, "::get_codes_for_year" do
  before do
    @codes_for_2012 = NaicsScraper.get_codes_for_year(2012)
  end
  it "gets a successful response from the API (or VCR)" do
    @codes_for_2012.response.code.should eq("200")
  end
  it "has items" do
    @codes_for_2012["items"].count.should be > 1
  end
end

describe NaicsScraper, "::get_content_for_code" do
  it "should return the correct description for 423120 in 2012 NAICS" do
    @code_content = NaicsScraper.get_content_for_code(423120, 2012)
    @code_content.should eq("This industry comprises establishments primarily engaged in the merchant wholesale distribution of motor vehicle supplies, accessories, tools, and equipment; and new motor vehicle parts (except new tires and tubes).")
  end
  # Issue #2 - May want to make this return the content for the referred code
  it "should return the a referential description for 51711 in 2012 NAICS" do
    @code_content = NaicsScraper.get_content_for_code(51711, 2012)
    @code_content.should eq("See industry description for 517110.")
  end
  it "should return nothing for a code without content (ex. 5412 in 2012)" do
    @code_content = NaicsScraper.get_content_for_code(5412, 2012)
    @code_content.should eq("")
  end
end

describe NaicsScraper, "::get_response_for_code" do
  # Part of the purpose of the below is to download pages to test above using VCR
  it "should return a successful response for a 2-digit code (54 in 2012)" do
    @response = NaicsScraper.get_response_for_code(423120, 2012)
    @response.code.should eq(200)
  end
  it "should return a successful response for a 3-digit code (541 in 2012)" do
    @response = NaicsScraper.get_response_for_code(423120, 2012)<commit_msg>Add test for 541120 in 2012<commit_after>require 'spec_helper'
require 'pry'

describe NaicsScraper, "::get_codes_for_year" do
  before do
    @codes_for_2012 = NaicsScraper.get_codes_for_year(2012)
  end
  it "gets a successful response from the API (or VCR)" do
    @codes_for_2012.response.code.should eq("200")
  end
  it "has items" do
    @codes_for_2012["items"].count.should be > 1
  end
end

describe NaicsScraper, "::get_content_for_code" do
  it "should return the correct description for 423120 in 2012 NAICS" do
    @code_content = NaicsScraper.get_content_for_code(423120, 2012)
    @code_content.should eq("This industry comprises establishments primarily engaged in the merchant wholesale distribution of motor vehicle supplies, accessories, tools, and equipment; and new motor vehicle parts (except new tires and tubes).")
  end
  # Issue #2 - May want to make this return the content for the referred code
  it "should return the a referential description for 51711 in 2012 NAICS" do
    @code_content = NaicsScraper.get_content_for_code(51711, 2012)
    @code_content.should eq("See industry description for 517110.")
  end
  it "should return nothing for a code without content (ex. 5412 in 2012)" do
    @code_content = NaicsScraper.get_content_for_code(5412, 2012)
    @code_content.should eq("")
  end
  it "should work for 541120 in 2012" do
    @code_content = NaicsScraper.get_content_for_code(541120,2012)
    @code_content.should eq("This industry comprises establishments (except offices of lawyers and attorneys) primarily engaged in drafting, approving, and executing legal documents, such as real estate transactions, wills, and contracts; and in receiving, indexing, and storing such documents.")
  end
end

describe NaicsScraper, "::get_response_for_code" do
  # Part of the purpose of the below is to download pages to test above using VCR
  it "should return a successful response for a 2-digit code (54 in 2012)" do
    @response = NaicsScraper.get_response_for_code(423120, 2012)
    @response.code.should eq(200)
  end
  it "should return a successful response for a 3-digit code (541 in 2012)" do
    @response = NaicsScraper.get_response_for_code(423120, 2012)
{'fraction_non_alphanumeric': 0.07317073170731707, 'fraction_numerical': 0.06738747799849132, 'mean_word_length': 4.658605974395448, 'pattern_counts': {'":': 6, '<': 3, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2103235', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1199, 'n_words': 453}