Sha256: 05cf084c5ef04e9857d857c6d1ad87e33ba117e4bca125ce6b48248e2ac8508a

Contents?: true

Size: 959 Bytes

Versions: 6

Compression:

Stored size: 959 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 -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

6 entries across 6 versions & 1 rubygems

Version Path
datamapper4rails-0.5.1 lib/datamapper4rails/integration_test.rb
datamapper4rails-0.5.0 lib/datamapper4rails/integration_test.rb
datamapper4rails-0.4.0 lib/datamapper4rails/integration_test.rb
datamapper4rails-0.3.2 lib/datamapper4rails/integration_test.rb
datamapper4rails-0.3.1 lib/datamapper4rails/integration_test.rb
datamapper4rails-0.3.0 lib/datamapper4rails/integration_test.rb