Created
October 18, 2012 22:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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