EDIT: The installation guide for OSX El Capitan can be found here: http://hackerforhire.com.au/installing-metasploit-framework-on-os-x-el-capitan/
This Guide is adapted from Carlos Perez’s Blog (http://www.darkoperator.com/installing-metasploit-framewor/) (which is a must read) with some additions and fixes to make the setup work on OS X Yosemite. This post should help to alleviate some common issues with installing ruby and the Metasploit Framework on OS X. The main issues being that OS X ships with a newer version of Ruby that is not compatible with Metasploit and the version of libiconv installed with OS X causes issues installing the Nokogiri gem.
Xcode and Command Line Development Tools
The first step is to ensure that Software Update has been run and that OS X is updated. Once OS X has been updated, It is time to install Xcode.
Once Xcode has been installed launch Xcode from Applications and agree to the SDK License Agreement.
Install Xcode developer tools by typing:
Click … read more