Created
April 7, 2011 16:47
-
-
Save probablykabari/908181 to your computer and use it in GitHub Desktop.
Dynamic model creation broken in DM 1.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'dm-core' | |
def create_dm_model(name) | |
DataMapper::Model.new(name) do | |
property :id, DataMapper::Property::Serial | |
property :name, DataMapper::Property::String | |
end | |
end | |
describe "Model Descendants" do | |
after(:each) do | |
DataMapper::Spec.cleanup_models | |
end | |
context "One Model" do | |
before(:each) do | |
create_dm_model("Foo") | |
end | |
it "should add a DM Model" do | |
Foo.should be_a_kind_of(DataMapper::Model) | |
end | |
it "should add model to descendants set" do | |
DataMapper::Model.descendants.should include(Foo) | |
end | |
end | |
context "Two Models" do | |
before(:each) do | |
create_dm_model("Foo") | |
create_dm_model("Bar") | |
end | |
it "should add a DM Model" do | |
Bar.should be_a_kind_of(DataMapper::Model) | |
Foo.should be_a_kind_of(DataMapper::Model) | |
end | |
it "should add model to descendants set" do | |
DataMapper::Model.descendants.should include(Bar) | |
DataMapper::Model.descendants.should include(Foo) | |
end | |
end | |
end |
Nope. It was never broken actually, it was just changed. It works the way it is done in the most recent gist.
DataMapper::Model.new(model_name)
Now the constant is set within that method, so no need for const_set, etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this still broken?
I just ran into this, and it's late so I'm posting a comment instead of checking this out for myself....