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. require 'rtml' unless defined?(Rtml::Widget) module Rtml; module WidgetCore; end; end 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(".") accessors = Rtml::Widget::RDOC_ACCESSORS.collect { |k,v| "#{k}=#{v}" }.join(",") files = FileList.new(['README.rdoc', 'History.txt', 'lib/**/*.rb', 'doc/**/*.rdoc', 'builtin/**/*.rb', 'rails_generators/*/*.rb'].collect { |fi| File.join(Rtml.root, fi) }) 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 if $root_dir t.ruby_opts << ['-r', File.join(Rtml.root, 'lib/rtml/init')] end if File.file?(File.join(RAILS_ROOT, "spec/spec_helper.rb")) t.ruby_opts << ['-r', File.join(RAILS_ROOT, "spec/spec_helper.rb")] 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 if defined?(RAILS_ROOT) && !$rtml_external puts "Make sure you've also run script/generate rspec, or you'll just see this" puts "message again." else puts "Make sure you've also got a spec folder, or you'll just see this message" puts "again." end end end task :noop end