Skip to content

Instantly share code, notes, and snippets.

@keithrbennett
Created October 18, 2012 22:23
Show Gist options
  • Select an option

  • Save keithrbennett/3915144 to your computer and use it in GitHub Desktop.

Select an option

Save keithrbennett/3915144 to your computer and use it in GitHub Desktop.
Peforms all steps necessary to create a Rails project that will use RSpec instead of TestUnit
#!/usr/bin/env ruby
# Creates a new Rails project configured to use
# rspec instead of TestUnit.
#
# - Keith Bennett, Github/Twitter: keithrbennett
ADD_RSPEC_COMMAND = %{
group :development, :test do
gem 'rspec-rails'
end
}
def run_command(command)
command << " 2>&1" # redirect stderr to stdout
puts command
puts `#{command}`
puts
end
PROJECT_NAME = ARGV[0]
run_command "rails new #{PROJECT_NAME} -T"
puts "Changing to project (#{PROJECT_NAME}) directory..."
Dir.chdir(PROJECT_NAME)
puts 'Adding rspec-rails to Gemfile...'
File.write('Gemfile', File.read('Gemfile') + ADD_RSPEC_COMMAND)
puts
puts 'Calling bundle install to process rspec-rails...'
run_command "bundle install"
puts 'Have rails install create spec directories/files...'
run_command "rails g rspec:install"
puts "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment