Created
June 16, 2013 10:11
-
-
Save floehopper/5791604 to your computer and use it in GitHub Desktop.
Run RSpec features separately from 'unit' specs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.