couchrest_model/spec/couchrest/more/property_spec.rb
Matt Aimonetti d6665e55ca Started on the ExtendedDocument class with features moved to mixins.
Properties got added, they define getters, setters and aliases.
They will also be the base of the new validation system.
2009-01-29 18:45:01 -08:00

36 lines
1 KiB
Ruby

require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
# check the following file to see how to use the spec'd features.
require File.join(FIXTURE_PATH, 'more', 'card')
describe "ExtendedDocument properties" do
before(:each) do
@card = Card.new(:first_name => "matt")
end
it "should be accessible from the object" do
@card.properties.should be_an_instance_of(Array)
@card.properties.map{|p| p.name}.should include("first_name")
end
it "should let you access a property value (getter)" do
@card.first_name.should == "matt"
end
it "should let you set a property value (setter)" do
@card.last_name = "Aimonetti"
@card.last_name.should == "Aimonetti"
end
it "should not let you set a property value if it's read only" do
lambda{@card.read_only_value = "test"}.should raise_error
end
it "should let you use an alias for an attribute" do
@card.last_name = "Aimonetti"
@card.family_name.should == "Aimonetti"
@card.family_name.should == @card.last_name
end
end