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.
This commit is contained in:
parent
90f460641e
commit
d6665e55ca
12 changed files with 539 additions and 8 deletions
|
@ -30,6 +30,9 @@ describe CouchRest::Document do
|
|||
end
|
||||
|
||||
describe "default database" do
|
||||
before(:each) do
|
||||
Video.use_database nil
|
||||
end
|
||||
it "should be set using use_database on the model" do
|
||||
Video.new.database.should be_nil
|
||||
Video.use_database @db
|
||||
|
@ -59,9 +62,11 @@ describe CouchRest::Document do
|
|||
@doc.rev.should be_nil
|
||||
@doc.id.should be_nil
|
||||
end
|
||||
|
||||
it "should freak out when saving without a database" do
|
||||
lambda{@doc.save}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# move to database spec
|
||||
|
|
36
spec/couchrest/more/property_spec.rb
Normal file
36
spec/couchrest/more/property_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue