Sha256: a3b883197ecbb7f50f19568ae5b58188b061d4ae4bba70b9363bed2c093d1a0d

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'rubygems'
require 'activerecord'
require 'active_record/connection_adapters/oracle_enhanced_adapter'

# $LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'legacy_data'

require 'spec'
require 'spec/autorun'

Spec::Runner.configure do |config|
  
end

### Load the rails generator code
require 'rails_generator'
require 'rails_generator/scripts'
require 'rails_generator/scripts/generate'

Rails::Generator::Base.reset_sources
def add_source(path)
  Rails::Generator::Base.append_sources(Rails::Generator::PathSource.new(:builtin, path))
end

add_source(File.dirname(__FILE__) + '/../generators')

def load_generator(generator_name="models_from_tables", args=[])
  Rails::Generator::Base.instance(generator_name,
                                  (args.dup << '--quiet'), 
                                  {:generator=>generator_name, :command=>:create, :destination=>RAILS_ROOT})    
end

def invoke_generator(generator_name, args, the_command= :create)
  generator = load_generator(generator_name, args)
  LegacyData::TableClassNameMapper.stub!(:log)    
  cmd = generator.command(the_command)
  cmd.stub!(:logger).and_return(stub('stub').as_null_object)
  cmd.invoke!
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legacy_data-0.1.1 spec/spec_helper.rb