-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
60 lines (54 loc) · 1.43 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
require "bundler/gem_tasks"
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "spec/**/*_spec.rb"
end
namespace :test do
desc "Run all tests (rake test will do this be default)"
task :all do
Rake::TestTask.new("all") do |t|
t.pattern = "spec/**/*_spec.rb"
end
task("all").execute
end
Dir.foreach("spec") do |dirname|
if File.directory?(File.join("spec", dirname))
desc "Run #{dirname} tests"
task dirname do
test_task = Rake::TestTask.new("#{dirname}tests") do |t|
t.test_files = Dir.glob(File.join("spec", dirname, "**", "*_spec.rb"))
end
task("#{dirname}tests").execute
end
end
end
desc "Run single controller"
task :controller, :file do |task, args|
test_task = Rake::TestTask.new("unittests") do |t|
if args.file
file = "spec/controllers/#{args.file}_spec.rb"
t.pattern = file
puts "Testing #{file}"
else
t.pattern = "spec/*_test.rb"
end
end
task("unittests").execute
end
desc "Run single file"
task :file, :file do |task, args|
test_task = Rake::TestTask.new("unittests") do |t|
if args.file
file = args.file
unless file.start_with? "spec/"
file = "spec/#{args.file}"
end
t.pattern = file
puts "Testing #{file}"
else
t.pattern = "spec/**/*_test.rb"
end
end
task("unittests").execute
end
end