[rspec-users] proposition: warn on rake spec - group :test

David Chelimsky dchelimsky at gmail.com
Fri Jul 30 09:09:59 EDT 2010


On Jul 30, 2010, at 3:09 AM, Rainer Kuhn wrote:
> On Jul 29, 3:29 pm, David Chelimsky <dchelim... at gmail.com> wrote:
>> On Jul 27, 2010, at 7:29 AM, Rainer Kuhn wrote:
>> 
>>> 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
>> 
>> 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


> 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$

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.


More information about the rspec-users mailing list