[rspec-users] generator-spec release 0.4.8
Kristian Mandrup
kmandrup.github at gmail.com
Wed Aug 11 12:02:04 EDT 2010
Now with an almost complete test suite to ensure it all works as it
should and to demonstrate how to use it.
The DSL is better than ever!
describe 'model_generator' do
# include Rails model helpers for ActiveRecord
# available:
# Other ORM options - :mongo_mapper, :mongoid and :data_mapper
# note: use_orm auto-includes the :model helper module
use_orm :active_record
# load helper modules and make available inside spec blocks
# here the module in rails_helpers/rails_migration is included
helpers :migration
before :each do
# define generator to test
setup_generator 'model_generator' do
tests Canable::Generators::ModelGenerator
end
# ensure clean state before each run
remove_model :account
end
after :each do
# ensure clean state after each run
remove_model :account
end
it "should not work without an existing Account model file"
do
with_generator do |g|
g.run_generator :account.args
g.should_not generate_file :account, :model
end
end
it "should decorate an existing Account model file with 'include
Canable:Ables'" do
with_generator do |g|
create_model :account
g.run_generator 'account'.args
g.should generate_model :account do |content|
content.should have_class :account do |klass|
klass.should include_module 'Canable::Ables'
end
end
end
end
end
More information about the rspec-users
mailing list