Basically, I have a bunch of folders in my spec directory for a rails project:
spec/acceptance spec/controllers spec/fixtures spec/helpers spec/javascripts spec/lib spec/mailers spec/models spec/support
The spec files in my acceptance folder are my capybara/selenium tests and still in experimental phase. I don’t want them to run every time and definitely don’t want the CI server running them. However, when I run ‘rake’ or ‘rake spec’, it runs everything in my ‘spec’ folder. I want it it to run the specs in every directory except acceptance.
I discovered there is not easy way to override a rake task. Redefining the task appends to it which to me is a pretty intuitive default behavior. Apparently, dchemsky knows about this and has opened an issue with rake. I was able to piece together a solution from an old blog post by Jay Fields.
Feel free to comment if you have a better way to do it.
require 'rake' require 'rspec/core/rake_task' class Rake::Task def abandon @actions.clear end end Rake::Task[:spec].abandon RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = "spec/{models,views,controllers,helpers}/**/*_spec.rb" end namespace :spec do desc "Run the code examples in spec/acceptance" RSpec::Core::RakeTask.new(:acceptance => "db:test:prepare") do |t| t.pattern = "spec/acceptance/**/*_spec.rb" end end