Testing rakes with rspec

Hi everyone, I’m having a very strange problem testing some rake tasks
with
rspec. I think I’m doing something terribly wrong here, and that’s why
rspec is having one of the weirdest behaviours I’ve ever seen…

Here is one of my rake tasks:

namespace :rivendell do
desc ‘Outputs the current version of Rivendell’
task version: :environment do
puts Rivendell::VERSION
end
end

And here is my spec (paths are alright):

describe ‘Rakefile’ do
before :all do
Rake.application.rake_require ‘…/tasks/rivendell’
Rake::Task.define_task :environment
end

describe 'rivendell::version' do
  # This doesn't appear to work
  let :run_rake_task do
    Rake::Task["rivendell::version"].reenable
    Rake.application.invoke_task "rivendell::version"
  end
  it 'should display the right version' do
    Rivendell.should_receive('VERSION').and_return('0.1')
    run_rake_task
  end
end

end

With this version, all tests pass (I invoke it directly with the rspec
command).
The problem is, if I change the should_receive call to
should_receive(‘sdjkakja’) it works as well, this suggests me I’m not
testing my code but some kind of weird double I’ve created (no idea how,
where or when).
Can someone please help me?

ngw