Sha256: d612a3b6c0d5a754e60f958d4d8fdac912bd0928f98b7479c2f4891842a0a780

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe "create" do
  
  describe "succeeds" do
    before(:each) do
      @comment = Comment.new :title => 'my_title'
      CouchPotato::Database.new(stub('database', :save_doc => {'rev' => '123', 'id' => '456'}, :info => nil)).save_document!(@comment)
    end

    it "should assign the id" do
      @comment._id.should == '456'
    end

    it "should assign the revision" do
      @comment._rev.should == '123'
    end

    it "should set created at" do
      @comment.created_at.should >= Time.now - 10
    end

    it "should set updated at" do
      @comment.updated_at.should >= Time.now - 10
    end
  end
  
  describe "fails" do
    before(:each) do
      @comment = Comment.new
      CouchPotato::Database.new(stub('database', :info => nil)).save_document(@comment)
    end

    it "should not assign an id" do
      @comment._id.should be_nil
    end

    it "should not assign a revision" do
      @comment._rev.should be_nil
    end

    it "should not set created at" do
      @comment.created_at.should be_nil
    end

    it "should set updated at" do
      @comment.updated_at.should be_nil
    end
    
    describe "with bank" do
      it "should raise an exception" do
        lambda {
          @comment.save!
        }.should raise_error
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
davber_couch_potato-0.4.0 spec/unit/create_spec.rb
couch_potato-0.4.0 spec/unit/create_spec.rb
couch_potato-0.3.2 spec/unit/create_spec.rb
couch_potato-0.3.1 spec/unit/create_spec.rb
davber_couch_potato-0.3.0 spec/unit/create_spec.rb
couch_potato-0.3.0 spec/unit/create_spec.rb
couch_potato-0.2.32 spec/unit/create_spec.rb
couch_potato-0.2.31 spec/unit/create_spec.rb
couch_potato-0.2.30 spec/unit/create_spec.rb
couch_potato-0.2.29 spec/unit/create_spec.rb
couch_potato-0.2.28 spec/unit/create_spec.rb