Technology and Software

No output from rake spec

I created a new Rails project, wrote some tests with rspec, run rake spec and got no output, only a single “** Invoke spec (first_time, not_needed)” line.

After a lot of googling and after learning a lot of things that nevertheless didn’t solve the problem I finally found this thread with the solution: add gem “rspec-rails” to the development group in the Gemfile.

I don’t why I should need the rspec gem in the development environment when rake spec runs in the test one (add “puts Rails.env” in one of your spec files and see) but that’s it. I tried to outsmart the framework and lost half an hour. I hope this will help somebody to google the solution faster!


3 thoughts on “No output from rake spec

  1. meandre says:

    this is really very very simple
    in general you’re in development environment. from there u wish to launch rake spec, but there is no rspec-rails dependency for this env, so the task is not found.
    environment-specific dependencies are specified in Gemfile with ‘group’ method and they influence which libs are being required at Rails startup.
    so the correct way to specify dependency would be:
    group :development, :test do
    # RSpec-Rails testing framework
    gem ‘rspec-rails’, ‘~> 2.6.1’

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s