Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Two spec examples for Property#get
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Feb 22, 2009
1 parent 5268f0f commit ba23742
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions spec/public/property_spec.rb
Expand Up @@ -154,9 +154,26 @@ class ::Image
end

describe "#get" do
it 'triggers loading for lazy loaded properties'
before(:all) do
@image = Image.create(:md5hash => "5268f0f3f452844c79843e820f9988691f44f9bc",
:title => "Rome at the sunset",
:description => "Just wow")
@image.should be_saved
# imitate "normal" load here to test lazy attributes load
# yes, we use dark ruby magic
@image.send(:remove_instance_variable, :@description)
Image.properties[:description].loaded?(@image).should be(false)
end

it 'triggers loading for lazy loaded properties' do
Image.properties[:description].get(@image)
Image.properties[:description].loaded?(@image).should be(true)
end

it 'sets original value'
it 'assigns loaded value to @ivar' do
Image.properties[:description].get(@image)
@image.instance_variable_get(:@description).should == "Just wow"
end

it 'sets default value for new records with nil value'

Expand Down

0 comments on commit ba23742

Please sign in to comment.