Sha256: 54be9069b1dead6589a201838dce3790c9342e8ee74a5e1187dc3d663fdbac98

Contents?: true

Size: 1.3 KB

Versions: 16

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe Alchemy::Picture do

  describe '#suffix' do

    it "should return the suffix of original filename" do
      pic = stub_model(Alchemy::Picture, :image_filename => 'kitten.JPG')
      pic.suffix.should == "jpg"
    end

    context "image has no suffix" do

      before(:each) do
        @pic = stub_model(Alchemy::Picture, :image_filename => 'kitten')
      end

      it "should return empty string" do
        @pic.suffix.should == ""
      end

    end

  end

  describe '#humanized_name' do

    it "should return a humanized version of original filename" do
      pic = stub_model(Alchemy::Picture, :image_filename => 'cute_kitten.JPG')
      pic.humanized_name.should == "Cute kitten"
    end

    it "should not remove incidents of suffix from filename" do
      pic = stub_model(Alchemy::Picture, :image_filename => 'cute_kitten_mo.jpgi.JPG')
      pic.humanized_name.should == "Cute kitten mo.jpgi"
      pic.humanized_name.should_not == "Cute kitten moi"
    end

    context "image has no suffix" do

      before(:each) do
        @pic = stub_model(Alchemy::Picture, :image_filename => 'cute_kitten')
        @pic.stub!(:suffix).and_return("")
      end

      it "should return humanized name" do
        @pic.humanized_name.should == "Cute kitten"
      end

    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
alchemy_cms-2.2.4 spec/models/picture_spec.rb
alchemy_cms-2.2.3.2 spec/models/picture_spec.rb
alchemy_cms-2.2.3.1 spec/models/picture_spec.rb
alchemy_cms-2.2.2 spec/models/picture_spec.rb
alchemy_cms-2.2.1 spec/models/picture_spec.rb
alchemy_cms-2.2.0 spec/models/picture_spec.rb
alchemy_cms-2.2.rc15 spec/models/picture_spec.rb
alchemy_cms-2.2.rc14 spec/models/picture_spec.rb
alchemy_cms-2.2.rc13 spec/models/picture_spec.rb
alchemy_cms-2.2.rc11 spec/models/picture_spec.rb
alchemy_cms-2.2.rc8 spec/models/picture_spec.rb
alchemy_cms-2.2.rc7 spec/models/picture_spec.rb
alchemy_cms-2.2.rc6 spec/models/picture_spec.rb
alchemy_cms-2.2.rc3 spec/models/picture_spec.rb
alchemy_cms-2.2.rc2 spec/models/picture_spec.rb
alchemy_cms-2.2.rc1 spec/models/picture_spec.rb