title: Testing Rake task with Rspec with Rails environment
body: <p>I'm trying to test a rake task and it uses an active record in it.</p>
  
  <pre><code>require 'spec_helper'
  require 'rake'
  
  load File.join(Rails.root, 'lib', 'tasks', 'survey.rake')
  
  describe "survey rake tasks" do
    describe "survey:send_report" do
      it "should send a report" do
        Rake::Task['survey:send_report'].invoke
      end
    end
  end
  </code></pre>
  
  <p>When I run this spec <code>rspec spec/lib/survey_spec.rb</code>, I get this error "</p>
  
  <pre><code>RuntimeError:
     Don't know how to build task 'environment'
  </code></pre>
  
  <p>How do I load the :enviroment task inside by example spec?</p>