Proposition: warn on rake spec - group :test

Consider putting out some information on rake spec, when rspec ist
only defined in the :test group.
This just cost me an hour until I read the blog post explaining it.

Thing is, rake spec doesn’t show on “rake -T” but it runs fine, just
not doing anything.
One line of output, like:

“Either use RAILS_ENV=test or put ‘gem rspec’ in the :development
group”

would be nice

Thanks
Ray

On Jul 27, 2010, at 7:29 AM, Rainer Kuhn wrote:

would be nice

RSpec can’t do anything if it’s not loaded, which is the case when you
run rake -T without rspec-rails in the :development group. I realize
that this is new, but this is the way Rails-3 is supposed to work and
we’re all going to be learning how Gemfiles work for a while. Note that
when you generate a new Rails-3 app (as of the release candidate), the
generated Gemfile says this:

Bundle gems for the local environment. Make sure to

put test-only gems in this group so their generators

and rake tasks are available in development mode:

group :development, :test do

gem ‘webrat’

end

HTH,
David

That’s not entirely true, there is a diffence between lot loaded and
not defined, let me show you:

This is without rspec in the dev group, so it does not show in rake -
T:

~/work/myproject$ rake spec
(in /Users/rainerkuhn/work/myproject)

~/work/myproject$ rake IdontExist
(in /Users/rainerkuhn/work/myproject)
rake aborted!
Don’t know how to build task ‘IdontExist’

(See full trace by running task with --trace)
~/work/myproject$

On Jul 30, 2010, at 3:09 AM, Rainer Kuhn wrote:

group :development, :test do

gem ‘webrat’

end

rake aborted!
Don’t know how to build task ‘IdontExist’

(See full trace by running task with --trace)
~/work/myproject$

Interesting. I see the same behaviour, but it’s not what you think it
is. Try “rake spec:models” and you’ll get the “Don’t know how to build”
error. I added a “raise” statement to the top of the rspec.rake file
(i.e. the first line - raises if the file is even loaded) and it raises
if I include rspec in the :development group, but not in the :test
group.

I then pulled rspec completely out of the Gemfile and, lo and behold,
still no error on “rake spec” - just does nothing.

Doesn’t solve this issue, but does verify that RSpec won’t be able to
solve it. It’ll have to come from either users getting used to the idea
of putting rspec-rails in the :development group, or a change to Rails.

ps - I moved your response from the top to the bottom. Please post
inline or at the bottom so readers can follow the thread:
http://idallen.com/topposting.html.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs