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).
I already posted on ruby-lang, I thought this place would be more 
appropriate.

TIA,
  ngw

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/9128a7c9-e7e0-41fa-aba4-978326becc9a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to