describe 'migration_generator' do
  include RSpec::Rails::Orm::ActiveRecord
  include RSpec::Rails::Migration
...
end

Didn't quite feel right. So I made it prettier DSL like using the
solution below ;)


class Class
  def use_orm orm
    class_eval do
      include "RSpec::Rails::Orm::#{orm.to_s.camelize}".constantize
    end
  end

  def specify_for type
    raise ArgumentError, "Can not specify for #{type}" if !
[:migration, :model].include?(type)
    class_eval do
      include "RSpec::Rails::#{type.to_s.camelize}".constantize
    end
  end
end

describe 'migration_generator' do
  use_orm :active_record
  specify_for :migration

  ...
end

Could it be done in a better way without polluting Class or some other
low lv Ruby class?
I want the functions from the included module to be avalable within
all my: before, after, it, describe etc. blocks.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to