The approved answer didn't work for me when I needed to complete my own rake task
Here is my solution
Insert the top of the specification file
require 'rake'
Put these lines where you need to execute your own rake command, for example. rake update_data strong> from example.rake file
load File.expand_path("../../../lib/tasks/example.rake", __FILE__)
My environment:
rails (4.0.0) ruby (2.0.0p195) rspec-core (2.14.7) rspec-expectations (2.14.3) rspec-mocks (2.14.4) rspec (2.14.1) rspec-rails (2.14.0)
Serge Seletskyy Nov 14 '13 at 11:49 2013-11-14 11:49
source share