2 namespace :merb_mart do
4 desc "Run slice specs within the host application context"
5 task :spec => [ "spec:explain", "spec:default" ]
9 slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
12 puts "\nNote: By running MerbMart specs inside the application context any\n" +
13 "overrides could break existing specs. This isn't always a problem,\n" +
14 "especially in the case of views. Use these spec tasks to check how\n" +
15 "well your application conforms to the original slice implementation."
18 Spec::Rake::SpecTask.new('default') do |t|
19 t.spec_opts = ["--format", "specdoc", "--colour"]
20 t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
23 desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
24 Spec::Rake::SpecTask.new('model') do |t|
25 t.spec_opts = ["--format", "specdoc", "--colour"]
27 t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
29 t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
33 desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
34 Spec::Rake::SpecTask.new('controller') do |t|
35 t.spec_opts = ["--format", "specdoc", "--colour"]
37 t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
39 t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
43 desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
44 Spec::Rake::SpecTask.new('view') do |t|
45 t.spec_opts = ["--format", "specdoc", "--colour"]
46 if(ENV['CONTROLLER'] and ENV['VIEW'])
47 t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
48 elsif(ENV['CONTROLLER'])
49 t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
51 t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
55 desc "Run all specs and output the result in html"
56 Spec::Rake::SpecTask.new('html') do |t|
57 t.spec_opts = ["--format", "html"]
58 t.libs = ['lib', 'server/lib' ]
59 t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort