You will get what you want by including require 'ruby-debug' at the top of your spec:

# spec/models/user_spec.rb
require 'spec_helper'
require 'ruby-debug'

describe User do
  it "should be valid" do
    debugger
    User.new.should be_valid
  end
end

You would then run rake spec or rspec as normal

NOTE: I now prefer Ruby 2.0+ and pry. It is pretty much the same process:

require 'spec_helper'
require 'pry-debugger'

describe User do
  it "should be valid" do
    binding.pry
    expect(User.new).to be_valid
  end
end

Also, I generally put requires like this in my spec_helper file, so that pry-debugger is available to all of my specs.


You can create an .rspec configuration file in the root of your project and include the line:

--debug