Skip to content

Instantly share code, notes, and snippets.

@brian-lc
Created November 8, 2010 02:45
Show Gist options
  • Select an option

  • Save brian-lc/667325 to your computer and use it in GitHub Desktop.

Select an option

Save brian-lc/667325 to your computer and use it in GitHub Desktop.
This is what you should put in the Rakefile for your gem to build in a test Rails app
namespace "testbed" do
RAPPNAME = "test_app" #This is also hardcoded in the spec/spec_helper.rb and gitignore file. Change it there too...
desc "Install rails base app in spec dir"
task :build_app do
directory "spec"
chdir("spec") do
sh "rails #{RAPPNAME}"
puts "Put a test_app in the spec folder"
chdir("#{RAPPNAME}") do
sh "ruby script/generate rspec"
puts "Ran plugin installer for rspec in #{RAPPNAME}"
end
end
end
desc "Copy in setup files to test app"
task :copy_files do
chdir("spec/#{RAPPNAME}") do
sh "cp ../test_Gemfile Gemfile"
sh "cp ../test_preinitializer.rb config/preinitializer.rb"
sh "cp ../test_boot.rb config/boot.rb"
puts "NOTE: These files were created/modified as described here: http://gembundler.com/rails23.html"
end
end
# You'll want to install your dev gem into the app but not quite yet
desc "Install gem plugin in rails base app, runs migrations, preps for testing"
task :install_gem_plugin do
# sh "gem install bclog"
# chdir("spec/#{RAPPNAME}") do
# sh "bundle install"
# sh "bundle exec script/generate bclog"
# sh "rake db:migrate"
# sh "rake db:test:prepare"
# end
# puts "NOTE: Run `gem uninstall bclog` to remove the gem version of surveyor leaving the dev version" # Getting around a bug/problem in bundler. see: http://bit.ly/9NZOEz
end
desc "Remove rails base app in spec dir"
task :remove_app do
puts "Removing the test_app in the spec folder"
sh "rm -rf spec/#{RAPPNAME}"
end
desc "Setup for the test app (create)"
task :setup => [:build_app, :copy_files, :install_gem_plugin]
desc "Teardown for the test app (remove)"
task :teardown => [:remove_app]
end # namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment