Sha256: d3d0f404e2750a9651712fd70162000e581b93e66b55196c6ad309f0201f5b33

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

class Document
  include CouchPotato::Persistence

  property :title
  property :content
end

describe 'new' do
  context 'without arguments' do
    subject { Document.new }

    it { is_expected.to be_a(Document) }

    it 'has no title' do
      expect(subject.title).to be_nil
    end

    it 'has no content' do
      expect(subject.content).to be_nil
    end
  end

  context 'with an argument hash' do
    subject { Document.new(title: 'My Title') }

    it { is_expected.to be_a(Document) }

    it 'has a title' do
      expect(subject.title).to eql('My Title')
    end

    it 'has no content' do
      expect(subject.content).to be_nil
    end
  end

  context 'yielding to a block' do
    subject do
      Document.new(title: 'My Title') do |doc|
        doc.content = 'My Content'
      end
    end

    it { is_expected.to be_a(Document) }

    it 'has a title' do
      expect(subject.title).to eql('My Title')
    end

    it 'has a content' do
      expect(subject.content).to eql('My Content')
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
couch_potato-1.17.0 spec/unit/initialize_spec.rb
couch_potato-1.16.0 spec/unit/initialize_spec.rb
couch_potato-1.15.0 spec/unit/initialize_spec.rb
couch_potato-1.14.0 spec/unit/initialize_spec.rb
couch_potato-1.13.0 spec/unit/initialize_spec.rb
couch_potato-1.12.1 spec/unit/initialize_spec.rb
couch_potato-1.12.0 spec/unit/initialize_spec.rb
couch_potato-1.11.0 spec/unit/initialize_spec.rb
couch_potato-1.10.1 spec/unit/initialize_spec.rb
couch_potato-1.10.0 spec/unit/initialize_spec.rb
couch_potato-1.9.0 spec/unit/initialize_spec.rb
couch_potato-1.7.1 spec/unit/initialize_spec.rb
couch_potato-1.7.0 spec/unit/initialize_spec.rb
couch_potato-1.6.5 spec/unit/initialize_spec.rb
couch_potato-1.6.4 spec/unit/initialize_spec.rb
couch_potato-1.6.3 spec/unit/initialize_spec.rb