Sha256: 1bfa5db14dae9f51b98db4738f84c78e0660f46724d29233d9bbd77445863407

Contents?: true

Size: 890 Bytes

Versions: 25

Compression:

Stored size: 890 Bytes

Contents

require 'spec_helper'

class Test
  include CouchPotato::Persistence

  property :test, :default => 'Test value'
  property :complex, :default => [1, 2, 3]
end

describe 'default properties' do
  before(:all) do
    recreate_db
  end

  it "should use the default value if nothing is supplied" do
    t = Test.new

    t.test.should == 'Test value'
  end

  it "should persist the default value if nothing is supplied" do
    t = Test.new
    CouchPotato.database.save_document! t

    t = CouchPotato.database.load_document t.id
    t.test.should == 'Test value'
  end

  it "should not have the same default for two instances of the object" do
    t = Test.new
    t2 = Test.new
    t.complex.object_id.should_not == t2.complex.object_id
  end
  
  it "should not return the default value when the actual value is empty" do
    t = Test.new(:complex => []).complex.should == []
  end
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
couch_potato-0.6.0 spec/default_property_spec.rb
couch_potato-0.5.7 spec/default_property_spec.rb
couch_potato-rails2-0.5.10 spec/default_property_spec.rb
couch_potato-rails2-0.5.9 spec/default_property_spec.rb
couch_potato-rails2-0.5.8 spec/default_property_spec.rb
couch_potato-rails2-0.5.7 spec/default_property_spec.rb
couch_potato-rails2-0.5.6 spec/default_property_spec.rb
couch_potato-0.5.6 spec/default_property_spec.rb
couch_potato-0.5.5 spec/default_property_spec.rb
couch_potato-0.5.4 spec/default_property_spec.rb
couch_potato-0.5.3 spec/default_property_spec.rb
couch_potato-0.5.2 spec/default_property_spec.rb
couch_potato-0.5.1 spec/default_property_spec.rb
couch_potato-0.5.0 spec/default_property_spec.rb
davber_couch_potato-0.4.0 spec/default_property_spec.rb
couch_potato-0.4.0 spec/default_property_spec.rb
couch_potato-0.3.2 spec/default_property_spec.rb
couch_potato-0.3.1 spec/default_property_spec.rb
davber_couch_potato-0.3.0 spec/default_property_spec.rb
couch_potato-0.3.0 spec/default_property_spec.rb