forked from thoughtbot/clearance
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
133 lines (111 loc) · 4.66 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# encoding: utf-8
ENV['BUNDLE_GEMFILE'] = File.dirname(__FILE__) + '/test/rails_root/Gemfile'
require 'rake'
require 'rake/testtask'
require 'cucumber/rake/task'
require 'spec/rake/spectask'
namespace :test do
Rake::TestTask.new(:basic => ["generator:cleanup",
"generator:clearance"]) do |task|
task.libs << "lib"
task.libs << "test"
task.pattern = "test/*/*_test.rb"
task.verbose = false
end
Rake::TestTask.new(:views => ["generator:cleanup",
"generator:clearance",
"generator:clearance_views"]) do |task|
task.libs << "lib"
task.libs << "test"
task.pattern = "test/*/*_test.rb"
task.verbose = false
end
Cucumber::Rake::Task.new(:features => ["generator:cleanup",
"generator:clearance",
"generator:clearance_features"]) do |t|
t.cucumber_opts = "--format progress"
t.profile = 'features'
end
Cucumber::Rake::Task.new(:features_for_views => ["generator:cleanup",
"generator:clearance",
"generator:clearance_features",
"generator:clearance_views"]) do |t|
t.cucumber_opts = "--format progress"
t.profile = 'features_for_views'
end
end
namespace :spec do
Spec::Rake::SpecTask.new(:basic => %w(spec:generator:cleanup spec:generator:clearance)) do |task|
task.spec_files = FileList['spec/*/*_spec.rb']
end
Spec::Rake::SpecTask.new(:views => %w(spec:generator:cleanup spec:generator:clearance spec:generator:clearance_views)) do |task|
task.spec_files = FileList['spec/*/*_spec.rb']
end
Cucumber::Rake::Task.new(:features => %w(spec:generator:cleanup spec:generator:clearance spec:generator:clearance_features)) do |task|
task.cucumber_opts = '--format progress'
task.profile = 'features_with_rspec'
end
Cucumber::Rake::Task.new(:features_for_views => %w(spec:generator:cleanup spec:generator:clearance spec:generator:clearance_features spec:generator:clearance_views)) do |task|
task.cucumber_opts = '--format progress'
task.profile = 'features_for_views_with_rspec'
end
namespace :generator do
task :cleanup do
FileList["spec/rails_root/db/**/*"].each do |each|
FileUtils.rm_rf(each)
end
FileUtils.rm_rf("spec/rails_root/vendor/plugins/clearance")
FileUtils.rm_rf("spec/rails_root/app/views/passwords")
FileUtils.rm_rf("spec/rails_root/app/views/sessions")
FileUtils.rm_rf("spec/rails_root/app/views/users")
FileUtils.mkdir_p("spec/rails_root/vendor/plugins")
clearance_root = File.expand_path(File.dirname(__FILE__))
system("ln -s #{clearance_root} spec/rails_root/vendor/plugins/clearance")
FileList["spec/rails_root/features/*.feature"].each do |each|
FileUtils.rm_rf(each)
end
end
task :clearance do
system "cd spec/rails_root && bundle install && ./script/rails generate clearance && rake db:migrate db:test:prepare"
end
task :clearance_features do
system "cd spec/rails_root && ./script/rails generate clearance_features"
end
task :clearance_views do
system "cd spec/rails_root && ./script/rails generate clearance_views"
end
end
end
namespace :generator do
desc "Cleans up the test app before running the generator"
task :cleanup do
FileList["test/rails_root/db/**/*"].each do |each|
FileUtils.rm_rf(each)
end
FileUtils.rm_rf("test/rails_root/app/views/passwords")
FileUtils.rm_rf("test/rails_root/app/views/sessions")
FileUtils.rm_rf("test/rails_root/app/views/users")
FileUtils.mkdir_p("test/rails_root/vendor/plugins")
clearance_root = File.expand_path(File.dirname(__FILE__))
FileList["test/rails_root/features/*.feature"].each do |each|
FileUtils.rm_rf(each)
end
end
desc "Run the clearance generator"
task :clearance do
system "cd test/rails_root && bundle install && ./script/rails generate clearance && rake db:migrate db:test:prepare"
end
desc "Run the clearance features generator"
task :clearance_features do
system "cd test/rails_root && ./script/rails generate clearance_features"
end
desc "Run the clearance views generator"
task :clearance_views do
system "cd test/rails_root && ./script/rails generate clearance_views"
end
end
desc "Run the test suite"
task :default => ['test:basic', 'test:features',
'test:views', 'test:features_for_views',
'spec:basic', 'spec:features',
'spec:views', 'spec:features_for_views']