Sha256: ce6e1f2613f023a5481faaeee2a4d63adef59b1d962ceb72306f4d6e5bbe9f6d

Contents?: true

Size: 1.31 KB

Versions: 30

Compression:

Stored size: 1.31 KB

Contents

require File.dirname(__FILE__) + '/../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

30 entries across 30 versions & 4 rubygems

Version Path
andrewtimberlake-couch_potato-0.2.8.1 spec/unit/create_spec.rb
andrewtimberlake-couch_potato-0.2.8.2 spec/unit/create_spec.rb
andrewtimberlake-couch_potato-0.2.8.3 spec/unit/create_spec.rb
andrewtimberlake-couch_potato-0.2.8.4 spec/unit/create_spec.rb
langalex-couch_potato-0.2.11 spec/unit/create_spec.rb
langalex-couch_potato-0.2.12 spec/unit/create_spec.rb
langalex-couch_potato-0.2.3 spec/unit/create_spec.rb
langalex-couch_potato-0.2.4 spec/unit/create_spec.rb
langalex-couch_potato-0.2.5 spec/unit/create_spec.rb
langalex-couch_potato-0.2.6 spec/unit/create_spec.rb
langalex-couch_potato-0.2.7 spec/unit/create_spec.rb
langalex-couch_potato-0.2.8 spec/unit/create_spec.rb
langalex-couch_potato-0.2.9 spec/unit/create_spec.rb
thefool808-couch_potato-0.2.7 spec/unit/create_spec.rb
couch_potato-0.2.27 spec/unit/create_spec.rb
couch_potato-0.2.26 spec/unit/create_spec.rb
couch_potato-0.2.25 spec/unit/create_spec.rb
couch_potato-0.2.24 spec/unit/create_spec.rb
couch_potato-0.2.23 spec/unit/create_spec.rb
couch_potato-0.2.22 spec/unit/create_spec.rb