Sha256: 6d92bed5c7f2123990e705e76d154fce4cecbee35165e952bce1b221f342be2a

Contents?: true

Size: 1.2 KB

Versions: 7

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe "create" do
  before(:all) do
    recreate_db
  end
  describe "succeeds" do
    it "should store the class" do
      @comment = Comment.new :title => 'my_title'
      CouchPotato.database.save_document! @comment
      CouchPotato.couchrest_database.get(@comment.id).send(JSON.create_id).should == '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
      CouchPotato.couchrest_database.get(@comment.id).created_at.should == 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
      CouchPotato.couchrest_database.get(@comment.id).updated_at.should == 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
      CouchPotato.couchrest_database.documents['rows'].should be_empty
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
davber_couch_potato-0.4.0 spec/create_spec.rb
couch_potato-0.4.0 spec/create_spec.rb
couch_potato-0.3.2 spec/create_spec.rb
couch_potato-0.3.1 spec/create_spec.rb
davber_couch_potato-0.3.0 spec/create_spec.rb
couch_potato-0.3.0 spec/create_spec.rb
couch_potato-0.2.32 spec/create_spec.rb