Sha256: a8472a572dfc32e52c54d601df4efc106cedd54a4424a57a72dc44f85d2059f8
Contents?: true
Size: 1.79 KB
Versions: 12
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper' describe "create" do before(:each) do recreate_db end describe "succeeds" do it "should store the class" do @comment = Comment.new :title => 'my_title' CouchPotato.database.save_document! @comment expect(CouchPotato.couchrest_database.get(@comment.id).send(JSON.create_id)).to eq('Comment') end it "should persist a given created_at" do @comment = Comment.new :created_at => Time.parse('2010-01-02 12:34:48 +0000'), :title => '-' CouchPotato.database.save_document! @comment expect(CouchPotato.couchrest_database.get(@comment.id).created_at).to eq(Time.parse('2010-01-02 12:34:48 +0000')) end it "should persist a given updated_at" do @comment = Comment.new :updated_at => Time.parse('2010-01-02 12:34:48 +0000'), :title => '-' CouchPotato.database.save_document! @comment expect(CouchPotato.couchrest_database.get(@comment.id).updated_at).to eq(Time.parse('2010-01-02 12:34:48 +0000')) end end describe "fails" do it "should not store anything" do @comment = Comment.new CouchPotato.database.save_document @comment expect(CouchPotato.couchrest_database.documents['rows']).to be_empty end end describe "multi-db" do TEST_DBS = ['comment_a', 'comment_b', 'comment_c'] before(:each) do TEST_DBS.each { |db_name| CouchPotato.couchrest_database_for_name(db_name).recreate! } end it "should create documents in multiple dbs" do TEST_DBS.each do |db_name| @comment = Comment.new(:title => 'my_title') CouchPotato.with_database(db_name) do |couch| couch.save_document! @comment end expect(CouchPotato.couchrest_database_for_name(db_name).get(@comment.id).send(JSON.create_id)).to eq('Comment') end end end end
Version data entries
12 entries across 12 versions & 1 rubygems