In this opportunity I'll explain (as the title suggests) how to go from a brand new mac os x to running Rails tests.
, is to make sure that
(you'll get some unexpected errors later on if not). To do so, you can either set the Language to one that Mac OS X sets UTF-8 by default, like United States from the System Preferences panel.
, you can run
$ export LC_ALL=en_US.UTF-8
$ export LANG=en_US.UTF-8
to achieve that.
, install Xcode.
, install osx-gcc-installer from
, So now you're ready to install Homebrew, by doing:
$ /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/go)"
Now this is how to install some common libraries
, We need to first have git in order run the brew doctor, so
$ brew install git
You can make sure that everything is ok by running
$ brew doctor
at any time. It should return '
Your system is raring to brew
' when in optimal conditions.
, now to install the rest of the libraries
$ brew install memcached mysql postgresql
, initializing the mysql and postgres databases must be done by doing
$ initdb /usr/local/var/postgres
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew
--prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
, I like having some aliases to load/unload mysql, postgres and memcached. To do so, you should add the following lines to your ~/.zshrc
alias memcached_load="launchctl load -w /usr/local/Cellar/memcached/1.4.13/homebrew.mxcl.memcached.plist"
alias memcached_unload="launchctl unload -w /usr/local/Cellar/memcached/1.4.13/homebrew.mxcl.memcached.plist"
alias mysql_load="launchctl load -w /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist"
alias mysql_unload="launchctl unload -w /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist"
alias postgres_load="launchctl load -w /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist"
alias postgres_unload="launchctl unload -w /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist"
, Now you're good to go. Next we'll install rbenv to easily switch between multiple versions of Ruby. You can also choose to use RVM or roll your own.
$ brew install rbenv ruby-build
eval "$(rbenv init -)"
, now do the following to install ruby
$ rbenv install 1.9.3-p125
, you need to
$ rbenv global 1.9.3-p125
$ rbenv rehash
, Cool, so now we are good to go and setup Rails.
$ git clone https://github.com/rails/rails.git
$ gem install bundler
$ rbenv rehash
$ cd rails
, now, from the Contributing to Rails Guide, you should
$ mysql -u root
mysql> GRANT ALL PRIVILEGES ON activerecord_unittest.* to 'rails'@'localhost';
mysql> GRANT ALL PRIVILEGES ON activerecord_unittest2.* to 'rails'@'localhost';
$ cd activerecord
$ rake mysql:build_databases
$ rake postgresql:build_databases
And that's it!, we have Ruby, MySQL, PostgreSQL, Memcached
, and everything needed to do some Rails development.
, we need to load Memcached for its needed for some tests by doing
, and lastly, you can run Rails tests by doing
at the top of the rails directory.
Everything should work just fine, or at least you should get the same results as the [Rails CI.](http://travis-ci.org/#!/rails/rails)