<commit_before>require 'spec_helper'

describe EphemeralResponse::Configuration do
  subject { EphemeralResponse::Configuration }

  describe "#fixture_directory" do
    it "has a default" do
      subject.fixture_directory.should == "spec/fixtures/ephemeral_response"
    end

    it "can be overwritten" do
      subject.fixture_directory = "test/fixtures/ephemeral_response"
      subject.fixture_directory.should == "test/fixtures/ephemeral_response"
    end
  end

  describe "#expiration" do
    it "defaults to 86400" do
      subject.expiration.should == 86400
    end

    it "can be overwritten" do
      subject.expiration = 43200
      subject.expiration.should == 43200
    end

    context "setting a block" do
      it "returns the value of the block" do
        subject.expiration = lambda { one_day * 7 }
        subject.expiration.should == 604800
      end

      it "raises an error when the return value of the block is not a FixNum" do
        expect do
          subject.expiration = lambda { "1 day" }
        end.to raise_exception(TypeError, "expiration must be expressed in seconds")
      end
    end
  end

  describe "#reset" do
    it "resets expiration" do
      subject.expiration = 1
      subject.expiration.should == 1
      subject.reset

      subject.expiration.should == 86400
    end

    it "resets fixture_directory" do
      subject.fixture_directory = "test/fixtures/ephemeral_response"
      subject.fixture_directory.should == "test/fixtures/ephemeral_response"
      subject.reset

      subject.fixture_directory.should == "spec/fixtures/ephemeral_response"
    end

    it "resets white_list" do
      subject.white_list = 'localhost'
      subject.white_list.should == ['localhost']
      subject.reset

      subject.white_list.should == []
    end

    it "resets skip_expiration" do
      subject.skip_expiration = true
      subject.skip_expiration.should == true
      subject.reset

      subject.skip_expiration.should == false
    end

    it "resets expiration, fixture directory, expiration, and white list to the defaults" do
    end

    it "resets white list after the default has been modified" do
      subject.white_list << "localhost"
      subject.reset
      subject.white_list.should be_empty
    end
  end

  describe "#white_list" do
    it "defaults to an empty array" do
      subject.white_list.should == []
    end

    it "allows hosts to be pushed onto the white list" do
      subject.white_list << 'localhost'
      subject.white_list << 'smackaho.st'
      subject.white_list.should == %w(localhost smackaho.st)
    end
  end

  describe "#white_list=" do
    it "sets a single host" do
      subject.white_list = 'localhost'
      subject.white_list.should == ['localhost']
    end

    it "sets multiple hosts" do
      subject.white_list = 'localhost', 'smackaho.st'
      subject.white_list.should == ['localhost', 'smackaho.st']
    end
  end
<commit_msg>Cleanup<commit_after>require 'spec_helper'

describe EphemeralResponse::Configuration do
  subject { EphemeralResponse::Configuration }

  describe "#fixture_directory" do
    it "has a default" do
      subject.fixture_directory.should == "spec/fixtures/ephemeral_response"
    end

    it "can be overwritten" do
      subject.fixture_directory = "test/fixtures/ephemeral_response"
      subject.fixture_directory.should == "test/fixtures/ephemeral_response"
    end
  end

  describe "#expiration" do
    it "defaults to 86400" do
      subject.expiration.should == 86400
    end

    it "can be overwritten" do
      subject.expiration = 43200
      subject.expiration.should == 43200
    end

    context "setting a block" do
      it "returns the value of the block" do
        subject.expiration = lambda { one_day * 7 }
        subject.expiration.should == 604800
      end

      it "raises an error when the return value of the block is not a FixNum" do
        expect do
          subject.expiration = lambda { "1 day" }
        end.to raise_exception(TypeError, "expiration must be expressed in seconds")
      end
    end
  end

  describe "#reset" do
    it "resets expiration" do
      subject.expiration = 1
      subject.expiration.should == 1
      subject.reset

      subject.expiration.should == 86400
    end

    it "resets fixture_directory" do
      subject.fixture_directory = "test/fixtures/ephemeral_response"
      subject.fixture_directory.should == "test/fixtures/ephemeral_response"
      subject.reset

      subject.fixture_directory.should == "spec/fixtures/ephemeral_response"
    end

    it "resets white_list" do
      subject.white_list = 'localhost'
      subject.white_list.should == ['localhost']
      subject.reset

      subject.white_list.should == []
    end

    it "resets skip_expiration" do
      subject.skip_expiration = true
      subject.skip_expiration.should == true
      subject.reset

      subject.skip_expiration.should == false
    end

    it "resets white list after the default has been modified" do
      subject.white_list << "localhost"
      subject.reset
      subject.white_list.should be_empty
    end
  end

  describe "#white_list" do
    it "defaults to an empty array" do
      subject.white_list.should == []
    end

    it "allows hosts to be pushed onto the white list" do
      subject.white_list << 'localhost'
      subject.white_list << 'smackaho.st'
      subject.white_list.should == %w(localhost smackaho.st)
    end
  end

  describe "#white_list=" do
    it "sets a single host" do
      subject.white_list = 'localhost'
      subject.white_list.should == ['localhost']
    end

    it "sets multiple hosts" do
      subject.white_list = 'localhost', 'smackaho.st'
      subject.white_list.should == ['localhost', 'smackaho.st']
    end
  end

{'fraction_non_alphanumeric': 0.08431440443213296, 'fraction_numerical': 0.012119113573407203, 'mean_word_length': 2.751298701298701, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, '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': '3861525', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1677, 'n_words': 474}