Sha256: 6b15306d0bd978cf93bd63b523fa40b9320d94dcae8403eb1ca72ab10548afae

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

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

describe StorageRoom::File do
  before(:each) do
    @file = StorageRoom::File.new
    @name = ::File.expand_path(File.dirname(__FILE__) + '/../../fixtures/image.png')
  end
  
  context "Class Methods" do
    describe "#new_with_filename" do
      it "return a new file object" do
        file = StorageRoom::File.new_with_filename(@name)
        file.should be_an_instance_of(StorageRoom::File)
        file.content_type.should == 'image/png'
        file.filename.should == 'image.png'
        file.data.should == ::Base64.encode64(::File.read(@name))
      end
    end
  end
  
  context "Methods" do
    describe "#set_with_filename" do
      it "should set with filename" do
        @file.set_with_filename(@name)
        
        @file.content_type.should == 'image/png'
        @file.filename.should == 'image.png'
        @file.data.should == ::Base64.encode64(::File.read(@name))
      end
      
      describe "#as_json" do
        it "should return hash" do
          @file.set_with_filename(@name)
          
          hash = @file.as_json.with_indifferent_access
          hash[:content_type].should == @file.content_type
          hash[:filename].should == @file.filename
          hash[:data].should == @file.data
        end
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
storage_room-0.3.5 spec/storage_room/embeddeds/file_spec.rb
storage_room-0.3.4 spec/storage_room/embeddeds/file_spec.rb
storage_room-0.3.3 spec/storage_room/embeddeds/file_spec.rb
storage_room-0.3.2 spec/storage_room/embeddeds/file_spec.rb