<commit_before>require 'spec_helper'
require 'stringio'

require 'pith/metadata'

describe Pith::Metadata do

  def metadata
    Pith::Metadata.extract_from(StringIO.new(@input))
  end
  
  describe "with input containing no YAML metadata" do
    
    before do
      @input = "%p Blah blah"
    end
    
    it "returns an empty Hash" do
      metadata.should == {}
    end
    
  end

  describe "with input containing YAML metadata" do
    
    before do
      @input = <<-HAML.gsub(/^ +/, '')
      -# ---
      -# x: 1
      -# y: "2"
      HAML
    end
    
    it "extracts the metadata" do<commit_msg>Check that other stuff can share a comment block with meta-data.<commit_after>require 'spec_helper'
require 'stringio'

require 'pith/metadata'

describe Pith::Metadata do

  def metadata
    Pith::Metadata.extract_from(StringIO.new(@input))
  end
  
  describe "with input containing no YAML metadata" do
    
    before do
      @input = "%p Blah blah"
    end
    
    it "returns an empty Hash" do
      metadata.should == {}
    end
    
  end

  describe "with input containing YAML metadata" do
    
    before do
      @input = <<-HAML.gsub(/^ +/, '')
      -# ---
      -# x: 1
      -# y: "2"
      -# ...
      -# other stuff
      HAML
    end
    
    it "extracts the metadata" do
{'fraction_non_alphanumeric': 0.10974673829623945, 'fraction_numerical': 0.0030698388334612432, 'mean_word_length': 2.0255220417633413, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4008830', 'n_tokens_mistral': 440, 'n_tokens_neox': 421, 'n_words': 129}