Sha256: 2a034fda417447dba827e15ed2261101f3f3692ece6cd24a9c88e5f23993ad9a

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

describe NanoStore do
  class Spaceship < NanoStore::Model
    attribute :name
  end

  def documents_path
    NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
  end

  after do
    path = documents_path + "/nano.db"
    File.delete(path) rescue nil
  end

  it "create :memory store" do
    store = NanoStore.store
    store.filePath.should == ":memory:"

    store = NanoStore.store :memory
    store.filePath.should == ":memory:"
  end
  
  it "create :persistent store" do
    path = documents_path + "/nano.db"
    store = NanoStore.store :persistent, path
    store.filePath.should == path    

    path = documents_path + "/nano.db"
    store = NanoStore.store :file, path
    store.filePath.should == path
  end
  
  it "create :temp store" do
    store = NanoStore.store :temp
    store.filePath.should == ""

    store = NanoStore.store :temporary
    store.filePath.should == ""
  end

  it "should use shared_store if a model has no store defined" do  
    NanoStore.shared_store = NanoStore.store
    Spaceship.store.should.not.be.nil
    NanoStore.shared_store.should.not.be.nil
    Spaceship.store.should == NanoStore.shared_store

    Spaceship.store = NanoStore.store :temp
    Spaceship.store.should.not == NanoStore.shared_store
  end
  
  it "should enable and disable debug mode" do
    NanoStore.debug = true    
    NanoStore.shared_store = NanoStore.store    
    NanoStore.debug = false
    NanoStore.shared_store.should.not.be.nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nano-store-0.6.3 spec/nano_store_spec.rb
nano-store-0.6.2 spec/nano_store_spec.rb
nano-store-0.6.1 spec/nano_store_spec.rb
nano-store-0.6.0 spec/nano_store_spec.rb