<commit_before>require 'spec_helper'

describe 'S3ImageFile' do

  let(:base_uid) { Pebblebed::Uid.new('image:path') }
  let(:aspect_ratio) { 1337 }
  let(:uid) { Pebblebed::Uid.new("image:path$timestamp-randomstr-extension-super-crazy-title-#{aspect_ratio}") }

  describe '#new' do
    it "takes an uid as parameter keeps the reference to it" do
      S3ImageFile.new(uid).uid.to_s.should eql "image:path$timestamp-randomstr-extension-super-crazy-title-1337"
    end
    it "fails if oid part of the uid is not set" do
      lambda { S3ImageFile.new(base_uid) }.should raise_error(S3File::IncompleteUidError)
    end
  end

  describe '#path' do
    it "includes the aspect ratio as a part of the path" do
      S3ImageFile.new(uid).path.should eql 'path/timestamp-randomstr-1337/super-crazy-title.extension'
    end
  end

  describe '#dirname' do
    it "takes an uid as parameter and figures out what the dirname will be" do
      S3ImageFile.new(uid).dirname.should eql 'path/timestamp-randomstr-1337'
    end
  end
end<commit_msg>Add specs for S3Image#path_for_size<commit_after>require 'spec_helper'

describe 'S3ImageFile' do

  let(:base_uid) { Pebblebed::Uid.new('image:path') }
  let(:aspect_ratio) { 1337 }
  let(:uid) { Pebblebed::Uid.new("image:path$31122012-randomstr-jpg-super-crazy-title-#{aspect_ratio}") }

  describe '#new' do
    it "takes an uid as parameter keeps the reference to it" do
      S3ImageFile.new(uid).uid.to_s.should eql "image:path$31122012-randomstr-jpg-super-crazy-title-1337"
    end
    it "fails if oid part of the uid is not set" do
      lambda { S3ImageFile.new(base_uid) }.should raise_error(S3File::IncompleteUidError)
    end
  end

  describe '#path' do
    it "includes the aspect ratio as a part of the path" do
      S3ImageFile.new(uid).path.should eql 'path/31122012-randomstr-1337/super-crazy-title.jpg'
    end
  end

  describe '#dirname' do
    it "takes an uid as parameter and figures out what the dirname will be" do
      S3ImageFile.new(uid).dirname.should eql 'path/31122012-randomstr-1337'
    end
  end
  describe '#path_for_size' do
    it "generates a path for a given size (version) of the image" do
      S3ImageFile.new(uid).path_for_size(200).should eql 'path/31122012-randomstr-1337/super-crazy-title_200.jpg'
    end
    it "generates a path for a given square-sized (version) of the image" do
      S3ImageFile.new(uid).path_for_size(200, :square => true).should eql 'path/31122012-randomstr-1337/super-crazy-title_200_sq.jpg'
    end
  end
end
{'fraction_non_alphanumeric': 0.11067036890122967, 'fraction_numerical': 0.045616818722729074, 'mean_word_length': 3.812977099236641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6621580', 'n_tokens_mistral': 964, 'n_tokens_neox': 896, 'n_words': 226}