Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

running "rails new foo --skip-test-unit" does not remote :test task from rake :default prerequisites #2564

Closed
bartocc opened this Issue · 14 comments

9 participants

@bartocc

with 3.1.0.rc.6

rails new foo --skip-test-unit
cd foo
bundle exec rake

=> Don't know how to build task 'test'

If I add this at the end of the Rakefile

raise Rake::Task[:default].inspect
=> [test]>

shouldn't the :test task be removed from the :default prerequisites ?

@mguterl

I came across the same thing and I thought this was a bug in rspec-rails (rspec/rspec-rails#438).

@tsaleh

Does anyone have a good workaround?

@bartocc

@tsaleh, you can do this in your Rakefile

Rake::Task[:default].prerequisites.clear
task :default => [:spec]

I'll see if I can submit a pull request to solve this issue

@tsaleh

Ah, clearing the prereq's did the trick! Thanks!

@raggi
task :test => :spec
@mguterl

This is all because railties/lib/tasks/misc.rake sets the default task to :test regardless of whether test unit is loaded or not.

https://github.com/rails/rails/blob/master/railties/lib/rails/tasks/misc.rake#L1

@mguterl

@raggi - nevermind, apparently I'm not actually reading.

@chrismytton

You can work around this by uncommenting the test_unit railtie in application.rb.

# Pick the frameworks you want:
# ...other railties
require "rails/test_unit/railtie"
@mguterl

@hecticjeff - then why have --skip-test-unit option in the first place?

@chrismytton

@mguterl Like I said, it's a workaround. This wasn't necessary before rails 3.1, so I think it must be a regression somewhere.

@josevalim josevalim closed this in 8a4239f
@hackeron

I have the same issue, I added this to my Rakefile:

Rake::Task[:test].prerequisites.clear
task :test => [:spec]
Rake::Task[:default].prerequisites.clear
task :default => [:spec]

But I'm still getting this:

# rake
rake aborted!
Don't know how to build task 'test'

(See full trace by running task with --trace)

Any ideas?

@ygt-mb

I still have same problem, did try all the solution above.
I can't invoke any rakes in Rspec tests.
gem 'rails', '3.2.6'
gem 'rspec', "~> 2.9.0"
gem 'rspec-rails', "~> 2.9.0"

@maxim

Make sure you

  1. have rspec-rails declared in the :development, :test group in your Gemfile
  2. don't have require: false set on rspec-rails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.