Sha256: 7ddf86e78a812c3448947f0fc3c0df226e03588e808e584fb1266b39b12c3b9a

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

module Datamapper4Rails
  class IntegrationTest
    
    attr_accessor :generator_args

    attr_accessor :rails_template

    attr_accessor :directory
    
    def initialize
      @ruby = RUBY_PLATFORM =~ /java/ ? 'jruby' : 'ruby'
      @directory = 'tmp'
      @generator_args = []
      @rails_template = 'datamapper_rails_templates.rb'
      yield self if block_given?
      execute
    end

    def generate(*args)
      @generator_args << args.join(" ")
    end

    def execute
      FileUtils.rm_rf(@directory)
      run("-S rails _2.3.8_ -fm #{rails_template} #{directory}")
      FileUtils.cd(@directory) do
        @generator_args.each do |arg|
          run("script/generate #{arg}")  
        end
        run("-S rake spec")
        #run("-S rake test:units")
      end

    end

    def run(command) 
      unless system("#{@ruby} #{command}")
        puts
        puts "error in: #{@ruby} #{command}"
        exit 1
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datamapper4rails-0.5.2 lib/datamapper4rails/integration_test.rb