begin require 'spec/rake/spectask' rescue MissingSourceFile end # This is a tiny bit faster than the bootstrapper because we can skip some of the dependencies, which matters a lot more # in potentially-often-run rake tasks. module Rtml; module WidgetCore; end; end require 'rtml' unless defined?(Rtml::Widget) require 'rtml/widget_core/class_methods' require 'rtml/widget' end namespace :rtml do desc "Generates RTML rdoc documentation in ./doc/rtml" Rake::RDocTask.new(:docs) do |rdoc| target_dir = File.expand_path(".") chdir Rtml.root accessors = Rtml::Widget::RDOC_ACCESSORS.collect { |k,v| "#{k}=#{v}" }.join(",") files = ['README.rdoc', 'History.txt', 'lib/**/*.rb', 'doc/**/*.rdoc', 'builtin/**/*.rb', 'rails_generators/*/*.rb'] rdoc.rdoc_files.add(files) rdoc.main = 'README.rdoc' rdoc.title = 'RubyTML 2.0 Documentation' #rdoc.template = '/path/to/gems/allison-2.0/lib/allison' rdoc.rdoc_dir = File.join(target_dir, 'doc/rtml') rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << accessors end desc 'Migrates the database. In a regular Rails project, this is the same as db:migrate.' task :migrate => 'db:migrate' desc 'Destroys the database. In a regular Rails project, this is the same as db:destroy.' task :destroy => 'db:destroy' desc 'Resets the database. In a regular Rails project, this is the same as db:reset.' task :reset => 'db:reset' desc 'Sets up the database. In a regular Rails project, this is the same as db:migrate.' task :setup => 'rtml:migrate' desc 'Runs the entire RTML test suite in the context of your Rails application' if defined?(Spec) && File.exist?(File.join($root_dir || RAILS_ROOT, 'spec')) # some of this was blatantly stolen from the rakefile built by script/generate rspec. Yeah, I have no pride. spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : 'noop' Spec::Rake::SpecTask.new(:test => spec_prereq) do |t| opts = "\"#{$root_dir || RAILS_ROOT}/spec/spec.opts\"" if File.exist?(opts) t.spec_opts = ['--options', opts] end t.spec_files = FileList[File.join(Rtml.root, "spec/**/*_spec.rb")] end else task :test do puts "You need to have rspec, rspec-rails and webrat installed before you can run" puts "in-place testing." puts puts "Make sure you've also run script/generate rspec, or you'll just see this" puts "message again." end end task :noop end