Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4315c5a986
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 46 lines (36 sloc) 0.965 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
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
Something went wrong with that request. Please try again.