Permalink
Browse files

revise README

  • Loading branch information...
1 parent 7445aa2 commit 4f68f0a91e78c0cfc89653f930f05a031c0e2c21 @siuying committed Mar 5, 2013
Showing with 18 additions and 2 deletions.
  1. +4 −2 README.md
  2. +14 −0 spec/model_spec.rb
View
@@ -49,10 +49,12 @@ If you are upgrading from an older version of nano-store gem, make sure you run
### Set default storage type
````ruby
-NanoStore.shared_store = NanoStore.store(:memory) # memory only db
+# memory only db
+NanoStore.shared_store = NanoStore.store(:memory)
+# file based db
documents_path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
-NanoStore.shared_store = NanoStore.store(:file, documents_path + "/nano.db") # persist the data
+NanoStore.shared_store = NanoStore.store(:file, documents_path + "/nano.db")
````
### Define Model
View
@@ -114,6 +114,20 @@ def stub_user(name, age, created_at)
user1.name.should == "Bob"
user1.created_at.should.be.nil
end
+
+ it "create model in file store" do
+ path = documents_path + "/nano.db"
+ NanoStore.shared_store = NanoStore.store :persistent, path
+
+ user = stub_user("Bob", 10, nil)
+ user.save
+
+ user1 = User.find(:name, NSFEqualTo, "Bob").first
+ user1.name.should == "Bob"
+ user1.created_at.should.be.nil
+
+ File.delete(path) rescue nil
+ end
end
describe "#delete" do

0 comments on commit 4f68f0a

Please sign in to comment.