Sha256: c11df0b8866f5c45c66c16682ae0c829061b1c8cca9bd930a726ec209adce8cf

Contents?: true

Size: 996 Bytes

Versions: 6

Compression:

Stored size: 996 Bytes

Contents

require 'spec_helper'
require 'json'

describe Snapshotar::Storage::FileStorage do

  TMP_DIR = "tmp"

  context "local file storage" do

    before(:all) do
      @fileStorage = described_class.new(TMP_DIR)

      # write a test file
      f = File.open(File.join(TMP_DIR,"test.json"), "w+")
      f.close

    end

    after(:all) do

      # clean up
      File.delete(File.join(TMP_DIR,"test.json"))
    end

    it "should initialize correctly" do
    end

    it "should list objects" do

      expect(@fileStorage.index).not_to be_empty
      expect(@fileStorage.index.count).to eq 1
    end

    it "should show one element" do

      expect(@fileStorage.show(@fileStorage.index.first)).not_to be_nil
    end

    it "should create an element" do

      @fileStorage.create("zz_testdump.json",{"test" => "this is a test object"}.to_json)

      expect(JSON.load(@fileStorage.show("zz_testdump.json"))).to have_key("test")

      @fileStorage.delete("zz_testdump.json")
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
snapshotar-0.0.7 spec/file_storage_spec.rb
snapshotar-0.0.6 spec/file_storage_spec.rb
snapshotar-0.0.4 spec/file_storage_spec.rb
snapshotar-0.0.3 spec/file_storage_spec.rb
snapshotar-0.0.2 spec/file_storage_spec.rb
snapshotar-0.0.1 spec/file_storage_spec.rb