Skip to content

Commit

Permalink
Make specs and bootstrap work in instance mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
seancribbs committed Jan 22, 2009
1 parent bc1ef30 commit d7c8502
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions 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]
Expand Down
14 changes: 6 additions & 8 deletions lib/tasks/instance.rake
@@ -1,22 +1,20 @@
# 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')

[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
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/release.rake
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/rspec.rake
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion 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')
Expand Down
3 changes: 2 additions & 1 deletion spec/generators/extension_generators_spec_helper.rb
Expand Up @@ -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')
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -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)
Expand Down

0 comments on commit d7c8502

Please sign in to comment.