This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Model inclusion/extension appending to work with defined models
* Added logic to Model#append_inclusions to add inclusions to all existing Model descendants * Added logic to Model#append_extensions to add extensions to all existing Model descendants * Added specs for behavior of Model.append_extensions and .append_inclusions [#1034 state:resolved] Signed-off-by: Dan Kubb <dan.kubb@gmail.com>
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper')) | ||
|
||
describe DataMapper::Model do | ||
|
||
it { should respond_to(:append_inclusions) } | ||
|
||
describe '.append_inclusions' do | ||
module ::Inclusions | ||
def new_method | ||
end | ||
end | ||
|
||
describe 'before the model is defined' do | ||
before :all do | ||
DataMapper::Model.append_inclusions(Inclusions) | ||
|
||
class ::User | ||
include DataMapper::Resource | ||
property :id, Serial | ||
end | ||
end | ||
|
||
it 'should respond to :new_method' do | ||
User.new.should respond_to(:new_method) | ||
end | ||
|
||
after :all do | ||
DataMapper::Model.extra_inclusions.delete(Inclusions) | ||
end | ||
end | ||
|
||
describe 'after the model is defined' do | ||
before :all do | ||
class ::User | ||
include DataMapper::Resource | ||
property :id, Serial | ||
end | ||
DataMapper::Model.append_inclusions(Inclusions) | ||
end | ||
|
||
it 'should respond to :new_method' do | ||
User.new.should respond_to(:new_method) | ||
end | ||
|
||
after :all do | ||
DataMapper::Model.extra_inclusions.delete(Inclusions) | ||
end | ||
end | ||
end | ||
|
||
it { should respond_to(:append_extensions) } | ||
|
||
describe '.append_extensions' do | ||
module ::Extensions | ||
def new_method | ||
end | ||
end | ||
|
||
describe 'before the model is defined' do | ||
before :all do | ||
DataMapper::Model.append_extensions(Extensions) | ||
|
||
class ::User | ||
include DataMapper::Resource | ||
property :id, Serial | ||
end | ||
end | ||
|
||
it 'should respond to :new_method' do | ||
User.should respond_to(:new_method) | ||
end | ||
|
||
after :all do | ||
DataMapper::Model.extra_extensions.delete(Extensions) | ||
end | ||
end | ||
|
||
describe 'after the model is defined' do | ||
before :all do | ||
class ::User | ||
include DataMapper::Resource | ||
property :id, Serial | ||
end | ||
DataMapper::Model.append_extensions(Extensions) | ||
end | ||
|
||
it 'should respond to :new_method' do | ||
User.should respond_to(:new_method) | ||
end | ||
|
||
after :all do | ||
DataMapper::Model.extra_extensions.delete(Extensions) | ||
end | ||
end | ||
end | ||
end |