Sha256: 34abc258816d812288e126ce751745b33f24bd3970daab3ef03e9aba50cccaa8

Contents?: true

Size: 1.22 KB

Versions: 8

Compression:

Stored size: 1.22 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe CarrierWave::Uploader do

  before do
    @uploader_class = Class.new(CarrierWave::Uploader::Base)
    @uploader = @uploader_class.new
  end

  after do
    FileUtils.rm_rf(public_path)
  end

  describe '#blank?' do
    it "should be true when nothing has been done" do
      @uploader.should be_blank
    end

    it "should not be true when the file is empty" do
      @uploader.retrieve_from_cache!('20071201-1234-345-2255/test.jpeg')
      @uploader.should be_blank
    end

    it "should not be true when a file has been cached" do
      @uploader.cache!(File.open(file_path('test.jpg')))
      @uploader.should_not be_blank
    end
  end

  describe '#read' do
    it "should be nil by default" do
      @uploader.read.should be_nil
    end

    it "should read the contents of a cached file" do
      @uploader.cache!(File.open(file_path('test.jpg')))
      @uploader.read.should == "this is stuff"
    end
  end

  describe '#size' do
    it "should be zero by default" do
      @uploader.size.should == 0
    end

    it "should get the size of a cached file" do
      @uploader.cache!(File.open(file_path('test.jpg')))
      @uploader.size.should == 13
    end
  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
jnicklas-carrierwave-0.2.3 spec/uploader/proxy_spec.rb
jnicklas-carrierwave-0.2.4 spec/uploader/proxy_spec.rb
jnicklas-carrierwave-0.3.0 spec/uploader/proxy_spec.rb
jnicklas-carrierwave-0.3.1 spec/uploader/proxy_spec.rb
carrierwave-0.3.0 spec/uploader/proxy_spec.rb
carrierwave-0.3.1 spec/uploader/proxy_spec.rb
carrierwave-0.2.4 spec/uploader/proxy_spec.rb
carrierwave-0.2.3 spec/uploader/proxy_spec.rb