<commit_before>require "spec_helper"

describe Sandy::Area do
  let(:customers_affected) { 100 }
  let(:options) { {} }

  describe "#customers_affected" do
    subject { Sandy::Area.new(customers_affected, nil).customers_affected }
    it { should == customers_affected }
  end

  describe "#to_s" do
    subject { Sandy::Area.new(customers_affected, "Manhattan").to_s }
    it { should == "Manhattan" }
  end

  describe "#to_json" do
    let(:parent) { Sandy::Area.new(0, "Manhattan") }
    subject { Sandy::Area.new(customers_affected, 
                              nil, { parent: parent }).to_json }

    it { should == {"name" => nil, 
                    "customers_affected" => customers_affected,
                    "parent" => parent.name,
                    "total_customers" => nil,
                    "latitude" => nil,
                    "longitude" => nil, 
                    "estimated_recovery_time" => nil,
                    "children" => [] }.to_json }<commit_msg>Make area json specs more fine grained.<commit_after>require "spec_helper"

describe Sandy::Area do
  let(:customers_affected) { 100 }
  let(:options) { {} }

  describe "#customers_affected" do
    subject { Sandy::Area.new(customers_affected, nil).customers_affected }
    it { should == customers_affected }
  end

  describe "#to_s" do
    subject { Sandy::Area.new(customers_affected, "Manhattan").to_s }
    it { should == "Manhattan" }
  end

  describe "#to_json" do
    let(:parent) { Sandy::Area.new(0, "Manhattan") }
    let(:current) { Sandy::Area.new(customers_affected, "Downtown", 
                                 { parent: parent }) }
    let(:child) { Sandy::Area.new(0, "Battery Park", { parent: current }) }
    let(:json) { current.to_json }

    it "parses with the correct values" do
      JSON.parse(json).should == {"name" => "Downtown", 
                                  "customers_affected" => customers_affected,
                                  "parent" => "Manhattan",
                                  "total_customers" => nil,
                                  "latitude" => nil,
                                  "longitude" => nil, 
                                  "estimated_recovery_time" => nil,
                                  "children" => [] }
    end

    it "renders only the name for the parent field" do
      JSON.parse(json)["parent"].should == "Manhattan"
    end
{'fraction_non_alphanumeric': 0.1303986710963455, 'fraction_numerical': 0.003737541528239203, 'mean_word_length': 1.9594594594594594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '64591', 'n_tokens_mistral': 749, 'n_tokens_neox': 670, 'n_words': 148}