<commit_before>require 'spec_helper'
require 'monet/capture'

describe Monet::Capture do
  Given(:path) { File.expand_path './spec/tmp/output' }
  Given(:url) { "http://google.com" }
  Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: url) }

  before do
    Timecop.freeze
  end

  after do
    Timecop.return

    Dir.glob("#{path}/*.png").each do |file|
      File.delete(file)
    end
  end

  context "can pass config" do
    context "as a hash" do
      Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: url) }
      When(:config) { capture_agent.instance_variable_get :@config }
      Then { config.should be_a(Monet::Config) }
      Then { config.capture_dir.should == path }
    end

    context "as a Monet::Config" do
      Given(:config) { Monet::Config.new(capture_dir: path, base_url: url) }
      Given(:capture_agent) { Monet::Capture.new(config) }
      When(:final) { capture_agent.instance_variable_get :@config }
      Then { final.should be_a(Monet::Config) }
      Then { final.capture_dir.should == path }
    end
  end

  context "converts name properly" do
    Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: url) }
    When { capture_agent.capture("/", 1024) }
    Then { File.exist?("#{path}/google.com/-1024.png").should be_true }
  end

  context "prepends default protocol if missing" do
    Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: "http://www.facebook.com") }
    When { capture_agent.capture('/', 1024) }
    Then { File.exist?("#{path}/www.facebook.com/-1024.png").should be_true }
  end

end<commit_msg>spec paths not getting cleared<commit_after>require 'spec_helper'
require 'monet/capture'

describe Monet::Capture do
  Given(:path) { File.expand_path './spec/tmp/output' }
  Given(:url) { "http://google.com" }
  Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: url) }

  before do
    Timecop.freeze
  end

  after do
    Timecop.return

    Dir.glob("#{path}/**/*.png").each do |file|
      File.delete(file)
    end
  end

  context "can pass config" do
    context "as a hash" do
      Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: url) }
      When(:config) { capture_agent.instance_variable_get :@config }
      Then { config.should be_a(Monet::Config) }
      Then { config.capture_dir.should == path }
    end

    context "as a Monet::Config" do
      Given(:config) { Monet::Config.new(capture_dir: path, base_url: url) }
      Given(:capture_agent) { Monet::Capture.new(config) }
      When(:final) { capture_agent.instance_variable_get :@config }
      Then { final.should be_a(Monet::Config) }
      Then { final.capture_dir.should == path }
    end
  end

  context "converts name properly" do
    Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: url) }
    When { capture_agent.capture("/", 1024) }
    Then { File.exist?("#{path}/google.com/google.com>-1024.png").should be_true }
  end

  context "prepends default protocol if missing" do
    Given(:capture_agent) { Monet::Capture.new(capture_dir: path, base_url: "http://www.facebook.com") }
    When { capture_agent.capture('/', 1024) }
    Then { File.exist?("#{path}/www.facebook.com/www.facebook.com>-1024.png").should be_true }
  end

end
{'fraction_non_alphanumeric': 0.14750150511739915, 'fraction_numerical': 0.00963275135460566, 'mean_word_length': 3.608876560332871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, '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': '2444984', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1099, 'n_words': 233}