Sha256: ede8ae8fdef067afb6ac3b14da5a300afdbb6094feab4e9abb156a563acabce9

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

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


describe "Jackfs File Adapter" do
  before(:each) do
    YAML.should_receive(:load_file).and_return("test" => {
      "adapter" => "file",
      "location" => 'tmp'
    })
    root = File.dirname(__FILE__) + '/..'

    @fa = Jackfs::FileAdapter.new(root, :test)
  end

  it "should save a file to a configured location" do
    Jackfs::FileAdapter.should be_truthy
    @fa.location.should == "tmp"
  end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jackfs-0.1.1 spec/adapters/file_adapter_spec.rb
jackfs-0.1.0 spec/adapters/file_adapter_spec.rb