Class: Datamapper4Rails::IntegrationTest

Inherits:
Object
  • Object
show all
Defined in:
lib/datamapper4rails/integration_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ IntegrationTest

Returns a new instance of IntegrationTest.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
16
17
# File 'lib/datamapper4rails/integration_test.rb', line 10

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

Instance Attribute Details

#directoryObject

Returns the value of attribute directory.



8
9
10
# File 'lib/datamapper4rails/integration_test.rb', line 8

def directory
  @directory
end

#generator_argsObject

Returns the value of attribute generator_args.



4
5
6
# File 'lib/datamapper4rails/integration_test.rb', line 4

def generator_args
  @generator_args
end

#rails_templateObject

Returns the value of attribute rails_template.



6
7
8
# File 'lib/datamapper4rails/integration_test.rb', line 6

def rails_template
  @rails_template
end

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/datamapper4rails/integration_test.rb', line 23

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

#generate(*args) ⇒ Object



19
20
21
# File 'lib/datamapper4rails/integration_test.rb', line 19

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

#run(command) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/datamapper4rails/integration_test.rb', line 36

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