Rake in Vim not working

Hi, I’m watching Ben Orenstein’s Vim for Rails Developers series. There he shows how to use :Rake to run Rspec tests inside of Vim.

But when I use this command I get:

 Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your     bundle if you use bundle --path) will improve the startup performance of Spring.
rake aborted!
Don't know how to build task 'test:prepare'

I gues it has something to do with Rails 4.1 and running rake db:test:prepare automatically.

Is there a way to get :Rake to work in a Rails 4.1 project?

thanks for your help,

Anthony

It might be that your default task is not set to run spec? Can you post your Rakefile contents? :Rake works for me with the following Rakefile contents using Rails 4.1

require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
task(:default).clear
task :default => [:spec]
1 Like

Hi Frank,

My Rakefile looks like this:

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks

I tried to get :Rake to work by adding

task(:default).clear
task :default => [:spec]

but that had no effect, if I type :Rake, I still get the same error message.

greetings,

Anthony

Refer to Update test requirements for 4.1 by JonRowe · Pull Request #946 · rspec/rspec-rails · GitHub. There was a fix for this in rspec-rails recently. Maybe you can try upgrading your gem to see if this solves the problem?

updated my rspec-rails gem, but it didn’t solve the problem.

When I run:

:Rake --trace

in the Vim cli I get:

|| Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling     your bundle if you use bundle --path) will improve the startup performance of Spring.
|| ** Invoke default (first_time)
|| ** Invoke spec (first_time)
|| rake aborted!
|| Don't know how to build task 'test:prepare'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task_manager.rb|62| in `[]'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|57| in `lookup_prerequisite'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|53| in `block in prerequisite_tasks'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|53| in `map'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|53| in `prerequisite_tasks'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|199| in `invoke_prerequisites'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|178| in `block in     invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb|211| in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|172| in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|201| in `block in invoke_prerequisites'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|199| in `each'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|199| in `invoke_prerequisites'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|178| in `block in     invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/monitor.rb|211| in `mon_synchronize'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|172| in `invoke_with_call_chain'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/task.rb|165| in `invoke'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|150| in `invoke_task'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|106| in `block (2 levels) in     top_level'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|106| in `each'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|106| in `block in top_level'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|115| in `run_with_threads'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|100| in `top_level'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|78| in `block in run'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|176| in     `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/rake-10.3.2/lib/rake/application.rb|75| in `run'
/Users/acandael/Sites/posplus/bin/rake|8| in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/dependencies.rb|241| in     `load'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/dependencies.rb|241| in     `block in load'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/dependencies.rb|232| in     `load_dependency'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.1/lib/active_support/dependencies.rb|241| in     `load'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb|55| in    `require'
/usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb|55| in    `require'
-e|1| in `<main>'
|| Tasks: TOP => default => spec