Skip to content

Instantly share code, notes, and snippets.

@floehopper
Created June 16, 2013 10:11
Show Gist options
  • Save floehopper/5791604 to your computer and use it in GitHub Desktop.
Save floehopper/5791604 to your computer and use it in GitHub Desktop.
Run RSpec features separately from 'unit' specs.
units = types.reject { |type, dir| type == 'features' }
namespace :spec do
desc "Run 'unit' specs: #{units.keys.to_sentence}"
RSpec::Core::RakeTask.new(:units) do |t|
t.pattern = units.map { |type, dir| "./#{dir}/**/*_spec.rb" }
end
end
default_task = Rake::Task['default']
prerequisites = default_task.prerequisites.dup
default_task.clear_prerequisites
new_prerequisites = %w(spec:units spec:features) + prerequisites - %w(spec)
task default: new_prerequisites
@floehopper
Copy link
Author

It makes me panic whenever I see a 'unit' spec take a long time and I immediately want to go to see why it's taking so long. At the moment RSpec features (including the JS-enabled ones) are run all mixed up within the same Rake task.

This file adds a new 'spec:units' Rake task and changes the default Rake task to depend on both 'spec:units' & 'spec:features' instead of 'spec'. Unfortunately given the constraints of Rake and RSpec Rails, I couldn't find a straightforward way to achieve the latter, so the code is a bit awkward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment