Permalink
Browse files

refactor rake task

  • Loading branch information...
1 parent a3affe3 commit 1e58eff7dbd1491e9e6bc66b69a89fa70ed2ad2a @JonRowe JonRowe committed Feb 26, 2014
Showing with 9 additions and 5 deletions.
  1. +9 −5 lib/rspec/rails/tasks/rspec.rake
@@ -3,14 +3,12 @@ if default = Rake.application.instance_variable_get('@tasks')['default']
default.prerequisites.delete('test')
end
-spec_prereq = Rails.configuration.generators.options[:rails][:orm] == :active_record ? "test:prepare" : :noop
-task :noop do; end
task :default => :spec
task :stats => "spec:statsetup"
desc "Run all specs in spec directory (excluding plugin specs)"
-RSpec::Core::RakeTask.new(:spec => spec_prereq)
+RSpec::Core::RakeTask.new(:spec => "spec:prepare")
namespace :spec do
types = begin
@@ -21,17 +19,23 @@ namespace :spec do
Hash[dirs.map { |d| [d.split('/').last, d] }]
end
+ task :prepare do
+ if Rails.configuration.generators.options[:rails][:orm] == :active_record
+ Rake::Task["test:prepare"].invoke
+ end
+ end
+
types.each do |type, dir|
desc "Run the code examples in #{dir}"
- RSpec::Core::RakeTask.new(type => spec_prereq) do |t|
+ RSpec::Core::RakeTask.new(type => "spec:prepare") do |t|
t.pattern = "./#{dir}/**/*_spec.rb"
end
end
# RCov task only enabled for Ruby 1.8
if RUBY_VERSION < '1.9'
desc "Run all specs with rcov"
- RSpec::Core::RakeTask.new(:rcov => spec_prereq) do |t|
+ RSpec::Core::RakeTask.new(:rcov => "spec:prepare") do |t|
t.rcov = true
t.pattern = "./spec/**/*_spec.rb"
t.rcov_opts = '--exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-,spec'

0 comments on commit 1e58eff

Please sign in to comment.