Skip to content

Commit

Permalink
break up the suite into smaller parts
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Feb 27, 2010
1 parent 247268d commit 885868e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 35 deletions.
48 changes: 33 additions & 15 deletions Rakefile
Expand Up @@ -40,24 +40,38 @@ rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end

namespace :generate do
desc "generate a fresh app with rspec installed"
task :app => :clobber_app do |t|
if File.directory?('./tmp/rails')
ruby "./tmp/rails/railties/bin/rails tmp/example_app --dev -m example_app_template.rb"
else
puts <<-MESSAGE
desc 'create app, generate a bunch of stuff, and run rake spec'
task :create_app do |t|
if File.directory?('./tmp/rails')
rm_rf "tmp/example_app"
ruby "./tmp/rails/railties/bin/rails tmp/example_app --dev -m example_app_template.rb"
else
puts <<-MESSAGE
You need to install rails in ./tmp/rails before you can run the
#{t.name} task:
git clone git://github.com/rails/rails tmp/rails
You need to install rails in ./tmp/rails before you can run the
#{t.name} task:
git clone git://github.com/rails/rails tmp/rails
(We'll automate this eventually, but running 'git clone' from rake in this
project is mysteriously full of fail)
(We'll automate this eventually, but running 'git clone' from rake in this
project is mysteriously full of fail)
MESSAGE
end
end

desc "generate a bunch of stuff with generators"
task :stuff do
Dir.chdir("./tmp/example_app/") do
sh "rake rails:template LOCATION='../../templates/generate_stuff.rb'"
end
end
end

MESSAGE
desc "run a variety of specs against the generated app"
task :run_specs do
Dir.chdir("./tmp/example_app/") do
sh "rake rails:template LOCATION='../../templates/run_specs.rb'"
end
end

Expand All @@ -66,5 +80,9 @@ task :clobber do
rm_rf "pkg"
end

task :default => :create_app
task :clobber_app do
rm_rf "tmp/example_app"
end

task :default => ["generate:app", "generate:stuff", :run_specs]

21 changes: 1 addition & 20 deletions example_app_template.rb
Expand Up @@ -4,24 +4,5 @@
# - would be nicer if we could source them from the <repo>/pkg dirs
gem 'rspec-rails', :path => File.expand_path('../../../', __FILE__)

run('bundle install')
generate('rspec:install')

run('script/rails g rspec:install')
run('script/rails g controller wombats index')
run('script/rails g integration_test widgets')
run('script/rails g mailer Notifications signup')
run('script/rails g model thing name:string')
run('script/rails g observer widget')
run('script/rails g scaffold widgets name:string')

run('rake db:migrate')
run('rake db:test:prepare')
run('rspec spec -cfdoc')
run('rake spec')
run('rake spec:requests')
run('rake spec:models')
run('rake spec:views')
run('rake spec:controllers')
run('rake spec:helpers')
run('rake spec:mailers')
run('rake stats')
7 changes: 7 additions & 0 deletions templates/generate_stuff.rb
@@ -0,0 +1,7 @@
generate('controller wombats index')
generate('integration_test widgets')
generate('mailer Notifications signup')
generate('model thing name:string')
generate('observer widget')
generate('scaffold widgets name:string')

11 changes: 11 additions & 0 deletions templates/run_specs.rb
@@ -0,0 +1,11 @@
run('rake db:migrate')
run('rake db:test:prepare')
run('rspec spec -cfdoc')
run('rake spec')
run('rake spec:requests')
run('rake spec:models')
run('rake spec:views')
run('rake spec:controllers')
run('rake spec:helpers')
run('rake spec:mailers')
run('rake stats')

0 comments on commit 885868e

Please sign in to comment.