Permalink
Browse files

Add Rake tasks for running uncommitted RSpec specs and tagged Cucumbe…

…r features
  • Loading branch information...
1 parent 6f9acf6 commit ec7b0d08ec41ac204b8d677c572c4923169b61db @njonsson committed Feb 28, 2013
Showing with 33 additions and 8 deletions.
  1. +33 −8 Rakefile
View
41 Rakefile
@@ -15,11 +15,31 @@ else
end
end
-Cucumber::Rake::Task.new :features, 'Test features' do |t|
- t.bundler = false
+def define_features_task(name, options)
+ Cucumber::Rake::Task.new name, options[:desc] do |t|
+ t.bundler = false
+ t.cucumber_opts = options[:cucumber_opts] if options.key?(:cucumber_opts)
+ end
+end
+
+define_features_task :features, :desc => 'Test features'
+
+tags = `grep -Ehr "^\\s*@\\S+\\s*$" features`.split("\n").
+ collect(&:strip).
+ uniq.
+ sort
+unless tags.empty?
+ namespace :features do
+ tags.each do |t|
+ define_features_task t.gsub(/^@/, ''),
+ :desc => "Test features tagged #{t}",
+ :cucumber_opts => "-t #{t}"
+ end
+ end
end
def define_spec_task(name, options={})
+ desc options[:desc]
RSpec::Core::RakeTask.new name do |t|
t.rspec_opts ||= []
unless options[:debug] == false
@@ -30,25 +50,30 @@ def define_spec_task(name, options={})
t.rspec_opts << '--debug'
end
end
- t.pattern = %w(spec/*_spec.rb spec/**/*_spec.rb)
+ t.pattern = options[:pattern] || %w(spec/*_spec.rb spec/**/*_spec.rb)
end
end
-desc 'Run specs'
-define_spec_task :spec
+define_spec_task :spec, :desc => 'Run specs'
+
+namespace :spec do
+ uncommitted_specs = `git ls-files --modified --others *_spec.rb`.split("\n")
+ desc = 'Run uncommitted specs'
+ desc += ' (none)' if uncommitted_specs.empty?
+ define_spec_task :uncommitted, :desc => desc, :pattern => uncommitted_specs
+end
desc 'Run specs and test features'
task '' => [:spec, :features]
task :default => [:spec, :features]
# Support the 'gem test' command.
namespace :test do
- desc ''
- define_spec_task :specs, :debug => false
+ define_spec_task :spec, :desc => '', :debug => false
Cucumber::Rake::Task.new :features, '' do |t|
t.bundler = false
t.cucumber_opts = '--backtrace'
end
end
-task :test => %w(test:specs test:features)
+task :test => %w(test:spec test:features)

0 comments on commit ec7b0d0

Please sign in to comment.