-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
81 lines (71 loc) · 2.08 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
begin
require 'bundler/gem_tasks'
rescue LoadError
end
require 'cucumber'
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
begin
require 'yard'
rescue LoadError
else
namespace :build do
YARD::Rake::YardocTask.new :doc
end
end
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
tags = `grep -Ehr "^\\s*@\\S+\\s*$" features`.split("\n").
collect(&:strip).
uniq.
sort
options = {:desc => 'Test features'}
options[:cucumber_opts] = '-t @focus' if tags.delete('@focus')
define_features_task :features, options
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
begin
require 'ruby-debug'
rescue LoadError
else
t.rspec_opts << '--debug'
end
end
t.pattern = options[:pattern] || %w(spec/*_spec.rb spec/**/*_spec.rb)
end
end
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
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:spec test:features)