These are steps i’ve found to work for me on Mac OSX.
rvm list
# will show you all Rubies installed in your current system, we have nothing because nothing has been installed
# if you haven't installed ruby 1.9.2
rvm install ruby-1.9.2-p180
# this will install Ruby 1.9.2 p180
rvm gemset create ruby-1.9.2-p180@rails31rc
rvm use ruby-1.9.2-p180@rails31rc
gem install rails -v ">=3.1.0rc"
rails new testproject -T
# -T means don't configure it with Test:Unit
cd testproject
# creates the .rvmrc file don't need echo
rvm --rvmrc use ruby-1.9.2-p180@rails31rc
vi Gemfile
Gemfile
# in Gemfile
group :development, :test do
gem 'database_cleaner'
gem 'rails3-generators'
gem 'rspec-rails'
gem 'factory_girl_rails'
end
Install Bundle
bundle install
Configure generators
vi config/application.rb
This is inside
module Testproject
class Application < Rails::Application
# this stuff goes in here.
end
end
config/application.rb file
# in config/application.rb
config.generators do |g|
# :views => false skips view spec generation
g.test_framework :rspec, :views => false, :fixture => true
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
turn on autoloading of lib and sub directories
# in config/application.rb
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]
install for rspec
rails g rspec:install
run db:migrate
rake db:migrate
a test scaffold
rails g scaffold Email email:string
run db:migrate
rake db:migrate
run specs
rake spec
Sources:
http://www.unfoldingcode.com/2011/05/using-rvm-to-install-rails-31-on-ubuntu.html
https://gist.github.com/989132