Sha256: e40234dbafe123aef0edc9bb3dd9e369a6c196f9469dd76d1b30b459965f10d7

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

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


describe "Jackfs Db Adapter" do
  before(:each) do
    File.delete("test.db") if File.exists?("test.db")
    YAML.should_receive(:load_file).and_return("test" => {
      "adapter" => "db",
      "connection" => 'sqlite://test.db',
      "table_name" => 'jackfs'
    })
    
    root = File.dirname(__FILE__) + '/..'
    @dba = Jackfs::DbAdapter.new(root, :test)
  end

  
  it "should save a file to a configured database name" do
    @dba.connection.should == 'sqlite://test.db'
  end


  it "should save a file to a configured table name" do
    @dba.table_name.should == 'jackfs'
  end

  it "should save the file in db using the given name" do
    @dba.store(File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r'),"COOLBEANS").should == true
  end

  # it "should get a file from a configured from db" do
  #   f = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
  #   @dba.store(f, "COOLBEANS")
  #   orig = File.open(File.dirname(__FILE__) + '/../fixtures/test.pdf', 'r')
  #   
  #   @dba.get("COOLBEANS").read.length.should == orig.read.length    
  # end
  
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jackfs-0.0.3 spec/adapters/db_adapter_spec.rb
jackfs-0.0.2 spec/adapters/db_adapter_spec.rb
jackfs-0.0.1 spec/adapters/db_adapter_spec.rb