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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to