0

I have a Rakefile in which I use to configure an environment for an application, I am having an issue where the Rake task is aborting because a particular Gem is installed in a preciding task.

Please see the Rakefile below, the Rake aborts on the line require 'data_mapper' within the :configure_db task, :configure_db is called by :build and it's preceding tasks are :bower_install and :bundle_install.

ENV['JASMINE_CONFIG_PATH'] = 'spec/js/support/jasmine.yml'

task :bower_install do
        system 'bower install'
end

task :bundle_install => :bower_install do
        system 'bundle install'
end

task :configure_db => :bundle_install do
        require 'data_mapper'

        DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/vela.db")

        require './models/User.rb'

        DataMapper.finalize
        DataMapper.auto_migrate!
end


desc "Starts the Rack server so we can run our tests"
task :default => :bundle_install do
        require 'sinatra'
        require 'rspec/core/rake_task'
        require 'jasmine'
        load 'jasmine/tasks/jasmine.rake'

        RSpec::Core::RakeTask.new(:spec)

        require './app'
    system 'rackup -D'
    Rake::Task["spec"].invoke
    Rake::Task["jasmine:ci"].invoke
end

task :build => :configure_db
Jacob Clark
  • 3,317
  • 5
  • 32
  • 61

1 Answers1

0

This Rakefile is equivalent to yours in terms of task dependencies:

task :a do
  puts 'running task a'
end

task :b => :a do
  puts 'running task b'
end

task :c => :b do
  puts 'running task c'
end

task :d => :c do
  puts 'running task d'
end

task :e => :c

It gives me the following results:

$ rake a
running task a

$ rake b
running task a
running task b

$ rake c
running task a
running task b
running task c

$ rake d
running task a
running task b
running task c
running task d

$ rake e
running task a
running task b
running task c

Isn't that exactly what you need? I don't see where the problem is.

Patrick Oscity
  • 53,604
  • 17
  • 144
  • 168
  • The problem is my rake file aborts because require 'data_mapper' is being executed before bundle install is executed. – Jacob Clark Jan 23 '14 at 15:54