diff --git a/CHANGELOG b/CHANGELOG index 59de67a75..ac379e72f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ == Change Log === Edge +* Make specs and bootstrap work in instance mode. [Sean Cribbs] * Override spec:integration task and rescope some spec task options to RADIANT_ROOT. [Sean Cribbs] * Improve rspec-1.1.12 compatibility. [Sean Cribbs] diff --git a/lib/tasks/instance.rake b/lib/tasks/instance.rake index 602ba89e7..503676f52 100644 --- a/lib/tasks/instance.rake +++ b/lib/tasks/instance.rake @@ -1,5 +1,5 @@ # Redefined standard Rails tasks only in instance mode -unless File.directory? "#{RAILS_ROOT}/app" +unless Radiant.app? require 'rake/testtask' ENV['RADIANT_ENV_FILE'] = File.join(RAILS_ROOT, 'config', 'environment') @@ -7,16 +7,14 @@ unless File.directory? "#{RAILS_ROOT}/app" [Dir["#{RADIANT_ROOT}/vendor/rails/railties/lib/tasks/*.rake"], Dir["#{RADIANT_ROOT}/vendor/plugins/rspec_on_rails/tasks/*.rake"]].flatten.each do |rake| lines = IO.readlines(rake) lines.map! do |line| - line.gsub!('RAILS_ROOT', 'RADIANT_ROOT') unless rake =~ /(misc|rspec)\.rake$/ + line.gsub!('RAILS_ROOT', 'RADIANT_ROOT') unless rake =~ /(misc|rspec|databases)\.rake$/ case rake when /testing\.rake$/ - line.gsub!(/t.libs << (["'])/, 't.libs << \1' + RADIANT_ROOT + '/') - line.gsub!(/t\.pattern = (["'])/, 't.pattern = \1' + RADIANT_ROOT + '/') + line.gsub!(/t.libs << (["'])/, 't.libs << \1#{RADIANT_ROOT}/') + line.gsub!(/t\.pattern = (["'])/, 't.pattern = \1#{RADIANT_ROOT}/') when /databases\.rake$/ - line.gsub!(/migrate\((["'])/, 'migrate(\1' + RADIANT_ROOT + '/') - when /rspec\.rake$/ - line.gsub!('RAILS_ROOT', 'RADIANT_ROOT') unless line =~ /:noop/ - line.gsub!(/FileList\[(["'])/, "FileList[\\1#{RADIANT_ROOT}/") + line.gsub!(/(migrate|rollback)\((["'])/, '\1(\2#{RADIANT_ROOT}/') + line.gsub!(/(run|new)\((:up|:down), (["'])db/, '\1(\2, \3#{RADIANT_ROOT}/db') end line end diff --git a/lib/tasks/release.rake b/lib/tasks/release.rake index 323606f90..a778cd083 100644 --- a/lib/tasks/release.rake +++ b/lib/tasks/release.rake @@ -58,6 +58,7 @@ namespace 'radiant' do files.exclude /^pkg/ files.include 'public/.htaccess' files.exclude /\btmp\b/ + files.exclude 'radiant.gemspec' s.files = files.to_a end diff --git a/lib/tasks/rspec.rake b/lib/tasks/rspec.rake index 35f81a183..5e7cf782a 100644 --- a/lib/tasks/rspec.rake +++ b/lib/tasks/rspec.rake @@ -61,7 +61,7 @@ namespace :spec do desc "Run the specs under spec/#{sub}" Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RADIANT_ROOT}/spec/spec.opts\""] - t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] + t.spec_files = FileList["#{RADIANT_ROOT}/spec/#{sub}/**/*_spec.rb"] end end diff --git a/lib/tasks/undefine.rake b/lib/tasks/undefine.rake index 56e3a26e2..171e3161c 100644 --- a/lib/tasks/undefine.rake +++ b/lib/tasks/undefine.rake @@ -1,5 +1,5 @@ # Undefined unneeded tasks in instance mode -unless File.directory? "#{RAILS_ROOT}/app" +unless Radiant.app? def undefine_task(*names) app = Rake.application tasks = app.instance_variable_get('@tasks') diff --git a/spec/generators/extension_generators_spec_helper.rb b/spec/generators/extension_generators_spec_helper.rb index f8cacae79..1274567b8 100644 --- a/spec/generators/extension_generators_spec_helper.rb +++ b/spec/generators/extension_generators_spec_helper.rb @@ -2,6 +2,7 @@ RAILS_ENV = 'test' BASE_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '../../')) require 'fileutils' +require 'tempfile' require 'spec' require File.join(BASE_ROOT, 'spec/matchers/generator_matchers') require File.join(BASE_ROOT, 'lib/plugins/string_extensions/lib/string_extensions') @@ -49,7 +50,7 @@ class InstanceTag; end end # Set RAILS_ROOT appropriately fixture generation - tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), "../fixtures/tmp")) + tmp_dir = File.expand_path(File.join(Dir.tmpdir, 'radiant')) $stdout << "#{tmp_dir}\n\n" FileUtils.mkdir_p tmp_dir diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 674e4bb58..e16987f2e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,7 +24,8 @@ def rputs(*args) class Test::Unit::TestCase include Dataset datasets_directory "#{RADIANT_ROOT}/spec/datasets" - + Dataset::ClassMethods.datasets_database_dump_path = File.expand_path(RAILS_ROOT + '/tmp/dataset') + class << self # Class method for test helpers def test_helper(*names)